HOW SHOULD DRAW THIS IN LOOP FORM? WHERE IS THE PROBLEM IN MY CODE?
Mostra commenti meno recenti
my code:s=0;
for n=1:0.01:10
s=s+(-1^n+1*sin(n*pi*x));
end
f=(2/pi)*s;
plot(x,f)
Where is wrong in my code?
4 Commenti
Walter Roberson
il 13 Dic 2018
x is not defined by your code, so it will have whatever value is sitting around in memory.
Walter Roberson
il 13 Dic 2018
You are defining x to have only 11 points, to exist only at the integers. Your required plot is clearly defined much denser than that.
HADIMARGO
il 13 Dic 2018
Risposta accettata
Più risposte (1)
madhan ravi
il 13 Dic 2018
x=linspace(-5,5,10000);
s=0;
for n=1:0.01:10
s=s+(-1^n+1*sin(n*pi*x));
end
f=(2/pi)*s;
plot(x,f)
1 Commento
HADIMARGO
il 13 Dic 2018
Categorie
Scopri di più su Functions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



