How do i make this form with matrix ?
조회 수: 3 (최근 30일)
이전 댓글 표시
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]
댓글 수: 0
채택된 답변
Voss
2022년 4월 1일
A = work5(0.5);
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
추가 답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!