showing unit using fprintf
Afficher commentaires plus anciens
How can I use fprintf to show the unit cm
without it looking like cm^2 ? I tried making unit=cm^2 but it just says cm is an unrecognized variable.
W = 0;
for i = 1:3
L = 1 ;
W = W+1 ;
A = (L*W);
unit = 1*(cm^2);
fprintf ('Length: %d\n', L)
fprintf ('Width: %d\n', W)
if L == W
disp ('The shape is square')
else
disp ('The shape is rectangle')
end
fprintf ('The area of the shape is: %.2f cm^2 \n', A)
disp (' ')
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!