필터 지우기
필터 지우기

How to shorten the amount of decimals?

조회 수: 2 (최근 30일)
Garrett
Garrett 2021년 5월 20일
댓글: Steven Lord 2021년 5월 20일
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)

채택된 답변

Star Strider
Star Strider 2021년 5월 20일
Use the digits function.
  댓글 수: 1
Steven Lord
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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by