it's plotting empty figures

조회 수: 1 (최근 30일)
Alex
Alex 2019년 10월 30일
댓글: Alex 2019년 10월 30일
i'm trying to plot two figures but it's plotting empty figure.
  댓글 수: 1
Bhaskar R
Bhaskar R 2019년 10월 30일
Actually it is not a problem of empty figures, there are errors. Code is wrong.

댓글을 달려면 로그인하십시오.

채택된 답변

Daniel M
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
Alex
Alex 2019년 10월 30일
that's really helpful thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
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...

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by