it's plotting empty figures
1 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Daniel M
2019-10-30
编辑:Daniel M
2019-10-30
I made some adjustments. Let me know if this is close to what you want.
tau = [1.5, 2];
figure
for t = 1:length(tau)
% create new vector tt (don't overwrite t)
tt = -tau(t):0.01:tau(t); % index tau at t
x = @(z) heaviside(z+tau(t)/2)-heaviside(z-tau(t)/2);
% use z for clarity, since the input variable doesn't need to be named t as well
subplot(1,2,t)
grid minor
plot(tt,x(tt)) % evaluate x at tt
end
更多回答(1 个)
Walter Roberson
2019-10-30
Change the
plot(t,x(t))
to
plot(t,x(t),'*')
I admit that I am surprised that subplot() did not give you an error about illegal subplot number, as you are constructing t as a vector of numeric values that are seldom positive integers. Notice that your line assigning t= -tau:0.01:tau is overwriting the t of your for t loop...
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!