How do i make this form with matrix ?

조회 수: 3 (최근 30일)
Ann Lee
Ann Lee 2022년 4월 1일
댓글: Voss 2022년 4월 1일
i want to make form like this picture with code.
(first a in forloop is series a, second a in forloop is series b, third a is seriesc)
and i got syntax error.
error
>> A=work5(0.5)
error: parse error near line 21 of file C:\Users\workspace\work5.m
syntax error
>>> fprintf('y-sum series a) series b) series c); %d %d %d',y,A]
^
could you check my code?
function A=work5(x)
m=1;
for k=10:10:160
n=1:k;
a= sum(nthroot(n.^2,5)./((3.^n).*(n+1)));
A(1,m)=a;
a= sum((3*n.^2+n)/(2*n.^4+nthroot(n,2)));
A(2,m)=a;
a= sum((nthroot(37,2)*n.^3)/((2*n.^3)+(3*n.^2)));
A(3,m)=a;
m=m+1;
end
y=[10:10:160]
fprintf('y-sum series a) series b) series c); %d %d %d',y,A]

채택된 답변

Voss
Voss 2022년 4월 1일
A = work5(0.5);
y-sum series a) series b) series c) 10-sum 0.23609170 0.01834773 2.60371306 20-sum 0.23609351 0.00469013 2.80141626 30-sum 0.23609351 0.00210244 2.87601971 40-sum 0.23609351 0.00118798 2.91522735 50-sum 0.23609351 0.00076243 2.93940338 60-sum 0.23609351 0.00053046 2.95580253 70-sum 0.23609351 0.00039026 2.96765763 80-sum 0.23609351 0.00029910 2.97662765 90-sum 0.23609351 0.00023652 2.98365156 100-sum 0.23609351 0.00019171 2.98930074 110-sum 0.23609351 0.00015852 2.99394282 120-sum 0.23609351 0.00013326 2.99782508 130-sum 0.23609351 0.00011359 3.00111997 140-sum 0.23609351 0.00009797 3.00395140 150-sum 0.23609351 0.00008537 3.00641075 160-sum 0.23609351 0.00007505 3.00856683
function A=work5(x)
m=1;
y = 10:10:160;
for k = y
n=1:k;
a= sum(nthroot(n.^2,5)./((3.^n).*(n+1)));
A(1,m)=a;
a= sum((3*n.^2+n)/(2*n.^4+nthroot(n,2)));
A(2,m)=a;
a= sum((nthroot(37,2)*n.^3)/((2*n.^3)+(3*n.^2)));
A(3,m)=a;
m=m+1;
end
fprintf('y-sum\t\t%-10s\t%-10s\t%-10s\n','series a)','series b)','series c)');
fprintf('%-d-sum\t\t%10.8f\t%10.8f\t%10.8f\n',[y; A]);
end
  댓글 수: 2
Ann Lee
Ann Lee 2022년 4월 1일
Thank you thank you!!!!
Voss
Voss 2022년 4월 1일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2022년 4월 1일
A = work5() ;
function A=work5()
m=1;
for k=10:10:160
n=1:k;
a= sum(nthroot(n.^2,5)./((3.^n).*(n+1)));
A(1,m)=a;
a= sum((3*n.^2+n)/(2*n.^4+nthroot(n,2)));
A(2,m)=a;
a= sum((nthroot(37,2)*n.^3)/((2*n.^3)+(3*n.^2)));
A(3,m)=a;
m=m+1;
end
y=10:10:160 ;
fprintf('y-sum series a) series b) series c); %d %d %d',y,A)
end
  댓글 수: 1
Ann Lee
Ann Lee 2022년 4월 1일
how do i type in comman window?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by