how to calculate %?

4 Ansichten (letzte 30 Tage)
Minh
Minh am 21 Sep. 2022
Kommentiert: Image Analyst am 22 Sep. 2022
I need to calculate % by dozens of formulas x = (x% 100) / 10 but in MATLAB behind % is a comment?

Akzeptierte Antwort

Image Analyst
Image Analyst am 21 Sep. 2022
Try this:
x = 23;
str = sprintf('%3.3d', x)
fprintf("hundreds :%s\n", str(1));
fprintf(" tens :%s\n", str(2));
fprintf(" units :%s\n", str(3));
x = 456
str = sprintf('%3.3d', x)
fprintf("hundreds :%s\n", str(1));
fprintf(" tens :%s\n", str(2));
fprintf(" units :%s\n", str(3));
  4 Kommentare
Minh
Minh am 22 Sep. 2022
i want to use formula to calculate but you helped me to do a simpler way that's what i asked for.!
Image Analyst
Image Analyst am 22 Sep. 2022
OK, then please Accept the best answer and "vote" for the other one.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by