plus/minus inside fprinf statement
183 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Marcus Darnell
el 18 de Sept. de 2019
Respondida: Josef Henthorn
el 28 de Oct. de 2020
Exaclty the title.
I know char(177) returns the plus/minus symbol but can't work out how to get it to display when matlab outputs to the command window.
fprintf('The measured volume of %fmm^{3} \x177 %fmm^{3} is equal to\nthe specified volume of %fmm^{3} \x177 %fmm^{3},\nand therefore the object passes quality inspection and can be released.\n',Vtot, DeltVrounded,VSpec,DeltaVSpec);
0 comentarios
Respuesta aceptada
Más respuestas (2)
dpb
el 18 de Sept. de 2019
pmchar=char(177);
fprintf(['The measured volume of %fmm^{3} ' pmchar '%fmm^{3} is equal to\nthe specified volume of %fmm^{3} ' pmchar '%fmm^{3},\nand therefore the object passes quality inspection and can be released.\n'], ...
Vtot, DeltVrounded,VSpec,DeltaVSpec);
I'd probably write the format string as a variable to be more readable, but that's just a style nit.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!