rounding string to certain decimal places
Mostra commenti meno recenti
%This command generates a random number. %Do not overwrite the value of number in your own code. number = 10*rand(1,1); %Enter the commands for your script mfile here. formatSpec = "The number rounded to two decimal places is %d."; A1 = round(number, 2) rounded_to_2 = sprintf(formatSpec,A1) formatSpec = "The number rounded to four decimal places is %d."; A1 = round(number, 4) rounded_to_4 = sprintf(formatSpec,A1) but the rounded value is not what I want. For example I want the value to be 5.34 but it displays 5.340000e+00
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Numeric Types in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!