Print results using fprintf in required format
3 views (last 30 days)
Show older comments
Prafulla Kumar Ambekar
on 17 Nov 2015
Commented: Naeem Khan
on 17 Jan 2018
Hi.
I have a matrix X = [3 2 5].
I want to display the results as
X1 = 3
X2 = 2
X3 = 5
I tried using
X= [3 2 5]
for(i=1:3)
t = i;
fprintf('\nThe value of X%0.0f ',i,' = %0.1f',X(t))
end
but results are ambiguous.
Kindly help with the correct syntax.
3 Comments
Naeem Khan
on 17 Jan 2018
try out this: X= [3 2 5] for(i=1:3) t = i; fprintf('\nThe value of X%0.0f',i) fprintf('=%0.0f',X(t)) end
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Multiobjective Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!