How to print variable and its value in the same line on Command Window
62 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Helena
el 6 de Abr. de 2023
Editada: Dyuman Joshi
el 6 de Abr. de 2023
Hi, I have this attribution in Command Window
I would like it to be shown as "a = 1", in the same line, without this line break after the equals. Do you know any setting that can change it? My version is R2022b.
Thanks
1 comentario
Dyuman Joshi
el 6 de Abr. de 2023
Editada: Dyuman Joshi
el 6 de Abr. de 2023
I don't think there is an option to change this particular display style/format.
Is there any particular reason you want to do this?
Respuesta aceptada
Joe Vinciguerra
el 6 de Abr. de 2023
To my knowledge, there is way to modify such line breaks in the output of a command as you're describing. But, depending on your objective, there are a couple options:
Use a semicolon after assigning the variable to suppress the output. That way "a = 1" is only on one line of the Command Window as the command.
a = 1;
If you still want to display the variable and value on a single line as an output of a command you could do this:
a = 1;
disp("a = " + num2str(a))
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!