it is not plotting
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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 Comments
Geoff Hayes
on 9 May 2015
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
on 9 May 2015
Meva
on 9 May 2015
Meva
on 9 May 2015
Geoff Hayes
on 9 May 2015
What are the minimum and maximum values of your xx and dp2dx arrays? Just do
min(xx)
max(xx)
min(dp2dx)
max(dp2dx)
dpb
on 9 May 2015
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
on 9 May 2015
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!