Borrar filtros
Borrar filtros

Remove zeros from a number

2 visualizaciones (últimos 30 días)
Saad Rana
Saad Rana el 4 de Jun. de 2020
Editada: Image Analyst el 4 de Jun. de 2020
Hi,
I want to preform calculations with a number excluding the zeros. The number is entered in a textbox so it's totally random.
for example, the user enters 2000, so can I extract 2 from this? Or say user enters 100000, can I extract only the non zero digit?
Thanks,
Rana

Respuesta aceptada

Image Analyst
Image Analyst el 4 de Jun. de 2020
Editada: Image Analyst el 4 de Jun. de 2020
Just get the edit box contents and set the 0's to nulls:
editBoxContents = handles.edit1.String;
editBoxContents(editBoxContents == '0') == []
If you want the number, just add
theNumber = str2double(editBoxContents);

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by