How can i implement following sum notation ?

Respuestas (2)

Bruno Luong
Bruno Luong el 16 de Abr. de 2022
call (without y=...)
soru(2,4)
Your function is not supposed to return any output

2 comentarios

cagri sarac
cagri sarac el 17 de Abr. de 2022
it does not work
Bruno Luong
Bruno Luong el 17 de Abr. de 2022
Editada: Bruno Luong el 17 de Abr. de 2022
"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
>>

Iniciar sesión para comentar.

Matt J
Matt J el 16 de Abr. de 2022
Editada: Matt J el 16 de Abr. de 2022
function y=soru(x,n)
y=sum( (3./x).^(1:n) );
end

Categorías

Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2020a

Etiquetas

Preguntada:

el 16 de Abr. de 2022

Editada:

el 17 de Abr. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by