How to dispaly result value?

1 Ansicht (letzte 30 Tage)
Mira le
Mira le am 13 Jun. 2023
Kommentiert: Mira le am 13 Jun. 2023
hello every one
I want to display results that I obtained
like this:
disp('N= '; N)
but it doesn't work

Akzeptierte Antwort

Dyuman Joshi
Dyuman Joshi am 13 Jun. 2023
Bearbeitet: Dyuman Joshi am 13 Jun. 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 Kommentare
Stephen23
Stephen23 am 13 Jun. 2023
fprintf('N=%d\n', N)
% ^^ probably with a newline afterwards
Mira le
Mira le am 13 Jun. 2023
Thank you so much it works

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by