MATLAB Answers

Array \ Matrix Output display formating

1 view (last 30 days)
For the next code
syms phi
M=exp(pi*tand(phi))*(tand(45+phi/2))^2;
phi=10:0.5:12;
for i=1:size(phi,2)
N(i)=vpa(subs(M,phi(i)));
end
the output is
[ 10, 2.4714356250900329077526825288117]
[ 21/2, 2.5879028921290203959454380144457]
[ 11, 2.7101851281117024394027253294966]
[ 23/2, 2.8386049798657898988231385226601]
[ 12, 2.973505374766345410079490037392]
how i could change the format to look like?
[ 10, 2.471]
[10.5, 2.587]
...
[ 12, 2.973]
i try
format shortG
but i think calling vpa function don't recive the format style defined before.
Thank you.
  2 Comments

Sign in to comment.

Accepted Answer

David Hill
David Hill on 19 Jun 2020
You could also round(x, 3) and use format shortG
format shortG;
syms phi
M=exp(pi*tand(phi))*(tand(45+phi/2))^2;
phi=10:0.5:12;
for i=1:size(phi,2)
N(i)=double(vpa(subs(M,phi(i))));
end
  1 Comment
Roberto Enrique Pinto Villegas
This was what i'm looking for... thank you so much!

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!