Help with this small exercise with input/output and ezplot

8 ビュー (過去 30 日間)
Carlo Speranza
Carlo Speranza 2018 年 12 月 3 日
回答済み: Bohdan Syrotiuk 2018 年 12 月 3 日
The exercise asks:
I wrote this matlab code
function y=sineseries(x,n)
x1=input('Insert the 1st value here -> ');
x2=input('Insert the 2nd value here -> ');
x3=input('Insert the 3rd value here -> ');
x4=input('Insert the 4th value here -> ');
x=[x1, x2, x3, x4];
n=input('Insert the integer index n-> ');
while n<0
disp('Error: n must be positive');
n=input('Insert n again -> ');
end
sol=0;
for k=1:n
s=(-1).^(k-1)*x.^(2*k-1)./factorial(2*k-1);
sol=sol+s;
end
format long
y=sol
end
My questions are:
1) how do I modify the code in order to have an appropriate y?
2) how do I use the command ezplot as it is asked in the exercise?

回答 (1 件)

Bohdan Syrotiuk
Bohdan Syrotiuk 2018 年 12 月 3 日
It's not a so easy excercise...

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by