Info

This question is closed. Reopen it to edit or answer.

how can i extend my graph to 10 secs by replicating it??

1 view (last 30 days)
t=[-1;-0.8;-0.6;-0.4;-0.2;0;0;0.2;0.4;0.6;0.8;0.8;1;];
Y=[-1;-1;-1;-1;-1;-1;1;1;1;1;1;-1;-1;]';
f=0;
N=10;
hold on;
h=zeros(N,1);
clr=lines(N);
for n=1:2:N;
line(t,Y,'linewidth',5)
grid on;hold on;
A=0.5*trapz(t,Y);
P=Y.*(cos(n*pi*t))';
Q=Y.*(sin(n*pi*t))';
Ax=trapz(t,P);
Bx=trapz(t,Q);
f=f+(Ax*cos(pi*n*t)+Bx*sin(pi*n*t));
final=A+f;
h(n)=plot(t,final,'linewidth',2,'Color',clr(n,:));
end
hold off;
legend(h, num2str((1:N)','harmonic-%d'))

Answers (1)

Image Analyst
Image Analyst on 23 Aug 2014
Replicating the graph ??? Like with subplot() or axes() so that you have two graphs/plots/axes???? Or do you mean replicating your data (with repmat)? Or extending the t axis out to 10 with xlim)? Please clarify!
  2 Comments
Image Analyst
Image Analyst on 24 Aug 2014
Did you try my suggestion of xlim()??? I imagine you must have by now , but it would look something like this:
xlim([-1, 10]);

Products

Community Treasure Hunt

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

Start Hunting!