How to shorten the amount of decimals?
조회 수: 2 (최근 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에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!