HOW I COULD DRAW THIS FUNCTION
Afficher commentaires plus anciens
Réponse acceptée
Plus de réponses (3)
madhan ravi
le 7 Déc 2018
Modifié(e) : madhan ravi
le 7 Déc 2018
Use cumsum() to define the behaviour of the alternating series:
x=linspace(0,50,10000);
n=1:10000;
y=(2/pi).*cumsum((((-1).^n+1).*(sin(pi.*x)))./n);
figure(1);
plot(x,y)

2 commentaires
madhan ravi
le 7 Déc 2018
Modifié(e) : madhan ravi
le 7 Déc 2018
Anytime :) , read more about cumsum() and linspace()
HADIMARGO
le 8 Déc 2018
0 votes
1 commentaire
Walter Roberson
le 8 Déc 2018
If you have TheResult = cumsum(SomeVector) then you can recode that in a loop as
TheResult(1) = SomeVector(1);
for LoopVariable = 2 : length(SomeVector)
TheResult(LoopVariable) = TheResult(LoopVariable-1) + SomeVector(LoopVariable);
end
... Approximately.
HADIMARGO
le 8 Déc 2018
0 votes
1 commentaire
Walter Roberson
le 8 Déc 2018
Yes, we could, but it is your homework.
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

