How to dispaly result value?

1 view (last 30 days)
Mira le
Mira le on 13 Jun 2023
Commented: Mira le on 13 Jun 2023
hello every one
I want to display results that I obtained
like this:
disp('N= '; N)
but it doesn't work

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!