it is not plotting
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hi,
I try this;
beta1 = 0.4*pi;
alphabar = 1;
dx=0.01;
for i=1:101
xx(i) = (i-1)*dx
end
dt=0.0001;
for nt=1:10001
t=(nt-1)*dt
...
if t==0.1
for i=1:101
t
if xx(i) < t
dp2dx(i) = -beta1-3*beta1^2.*xx(i);
else
dp2dx(i) = -beta1+2.*xx(i)*(-beta1*alphabar-1.5*beta1^2) + ...
t*2*beta1*alphabar;
end
end
figure(16)
plot(xx,dp2dx)
where xx(i) = (i-1)*0.01. But it is not plotting. Any suggestions??
댓글 수: 10
Geoff Hayes
2015년 5월 9일
Meva - what are the dimensions of xx and dp2dx? What is the maximum value of xx? Note how you have a condition
if xx(i) < t
Is this ever satisfied?
Meva
2015년 5월 9일
Meva
2015년 5월 9일
Meva
2015년 5월 9일
Geoff Hayes
2015년 5월 9일
What are the minimum and maximum values of your xx and dp2dx arrays? Just do
min(xx)
max(xx)
min(dp2dx)
max(dp2dx)
dpb
2015년 5월 9일
Doesn't answer the question raised...you're assuming something is happening that may not be. As Geoff, says, "show us".
You say "it is not plotting"; what is happening, specifically?
I note you have
figure(16)
in the script before plot---you sure you're looking at the proper figure or have you got the axes there fixed outside the bounds of the data from a previous iteration or somesuch? We can't know these things from here.
I'd suggest just
figure
plot(...
and see wht happens.
NB: Besides the < test Geoff asks about, you also have the conditional
if t==0.1
containing the whole rest of the code snippet. Relying on floating point exact comparison is risky altho in this case it should work as you have an integer multiple of a delta but in general you can't count on a computed floating point value being identical to the constant to the last significant bit; you really should double-check this is actually happening here as well and write the test as
if abs(t-CONDITION)<3*eps(t)
or somesuch other appropriate for the case relative error value.
Meva
2015년 5월 9일
답변 (0개)
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!