How can i implement following sum notation ?

답변 (2개)

Bruno Luong
Bruno Luong 2022년 4월 16일

1 개 추천

call (without y=...)
soru(2,4)
Your function is not supposed to return any output

댓글 수: 2

cagri sarac
cagri sarac 2022년 4월 17일
it does not work
Bruno Luong
Bruno Luong 2022년 4월 17일
편집: Bruno Luong 2022년 4월 17일
"it does not work"
Your function still have problem it doesn't compute what you expect (I'm not here to do entirely the homework for you) but it certainly not longer throw an error:
function soru(x,n)
sum = 0;
k = 1;
prompt1="enter x ";
prompt2="enter n ";
x=input(prompt1);
n=input(prompt2);
for loop=k:n
sum=((3/x)^k)+sum;
end
disp(sum)
end
Result runing on my PC
>> soru(2,4)
enter x 1
enter n 10
30
>>

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

Matt J
Matt J 2022년 4월 16일
편집: Matt J 2022년 4월 16일

0 개 추천

function y=soru(x,n)
y=sum( (3./x).^(1:n) );
end

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2022년 4월 16일

편집:

2022년 4월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by