How to dispaly result value?

hello every one
I want to display results that I obtained
like this:
disp('N= '; N)
but it doesn't work

 Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 13 de Jun. de 2023
Editada: Dyuman Joshi el 13 de Jun. de 2023
Use sprintf with disp
N=5;
%Create text
str = sprintf('N=%d', N); %d is the modifier for signed integer
%see the links attached for more info
%Display
disp(str)
N=5
or use fprintf
%Directly displays or prints the text input
fprintf('N=%d', N)
N=5

2 comentarios

Stephen23
Stephen23 el 13 de Jun. de 2023
fprintf('N=%d\n', N)
% ^^ probably with a newline afterwards
Mira le
Mira le el 13 de Jun. de 2023
Thank you so much it works

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Productos

Versión

R2017a

Preguntada:

el 13 de Jun. de 2023

Comentada:

el 13 de Jun. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by