How to shorten the amount of decimals?
7 次查看(过去 30 天)
显示 更早的评论
I keep getting really long numerical values as output:
An =
0.024234995896557227359496464702679*alpha
0.15943782393832228295849338860996*alpha
-0.12536421301907562828842055676579*alpha
-0.03553313448766475646513348990721*alpha
-0.13243736773001789371670675334921*alpha
-1.1264101534225156844164497805098*alpha
0.032972016135334102699585911872833*alpha
0.10090249826183501633095025194958*alpha
0.094800519200094255394106279895626*alpha
-0.031355837620080097288391753550103*alpha
How can i reduce this to only a couple decimal places?
Entire code for reference:
clc
clear
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)
0 个评论
采纳的回答
Star Strider
2021-5-20
1 个评论
Steven Lord
2021-5-20
You can instead call vpa with two inputs if you don't want to affect the number of digits for future calls.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!