Info
此问题已关闭。 请重新打开它进行编辑或回答。
how can i extend my graph to 10 secs by replicating it??
1 次查看(过去 30 天)
显示 更早的评论
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'))
0 个评论
回答(1 个)
Image Analyst
2014-8-23
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 个评论
Image Analyst
2014-8-24
Did you try my suggestion of xlim()??? I imagine you must have by now , but it would look something like this:
xlim([-1, 10]);
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!