How to shorten the amount of decimals?

2 views (last 30 days)
Garrett on 20 May 2021
Commented: Steven Lord on 20 May 2021
I keep getting really long numerical values as output:
An =
How can i reduce this to only a couple decimal places?
Entire code for reference:
N = 19;
AR = 6;
n =1:2:N;
b = 6;
Vinf = 1;
c = 1;
deltay = b./(N+1);
y0n = -(b./2)+n.*deltay;
syms alpha
A = sym('A', [1, N]);
A = A(1:2:end);
Pi = sym(pi);
theta = (linspace((Pi/6),(Pi/2),numel(n)).');
S1 = sum(A.*sin(n.*(theta)));
S2 = sum(n.*A.*(sin(n.*(theta))./sin((theta))));
eq1 = (2*AR/pi)*S1+S2 == alpha;
[A,b] = equationsToMatrix(eq1, A);
x = linsolve (A,b);
An = vpa(x)

Accepted Answer

Star Strider
Star Strider on 20 May 2021
Use the digits function.
  1 Comment
Steven Lord
Steven Lord on 20 May 2021
You can instead call vpa with two inputs if you don't want to affect the number of digits for future calls.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by