Hello there. I ran a matlab program and i cant produce any graph. This program can run but it doesnt show any graph.. Please help me
Show older comments
L = 1.;
T = 1.;
maxk = 2500;
dt = T/maxk;
n=50;
dx = L/n;
cond = 1/4;
b = 2.*cond*dt/(dx*dx);
for i= 1:n+1
x(i) = (i-1)*dx;
u(i,1) = sin(pi*x(i));
end
for k=1:maxk+1
u(1,k) = 0.;
u(n+1,k)=0.;
time(k) = (k-1)*dt;
end
for k=1:maxk
for i=2:n;
u(i,k+1)=u(i,k)+0.5*b*(u(i-1,k)+u(i+1,k)-2.*u(i,k));
end
end
figure (1)
plot (x,u(:,1),'-',x,u(:,100),'-',x,u(:,300),'-',x,u(:,600),'-')
title ('Temperature within the explicit method')
xlabel ('X')
ylabel ('Y')
figure (2)
mesh (x,time,u')
title ('Temperature within the explicit method')
xlabel ('X')
ylabel ('Temperature')
3 Comments
dpb
on 15 Oct 2013
Format the code to be legible...
iwan
on 15 Oct 2013
Image Analyst
on 15 Oct 2013
Edited: Image Analyst
on 15 Oct 2013
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup. Also, before you paste your code in here, type control-a and then control-i in the MATLAB editor to fix the indenting.
Answers (2)
Image Analyst
on 15 Oct 2013
0 votes
I copied and pasted your code and it made beautiful plots for me. Are you saying that no figure windows at all are created?
2 Comments
iwan
on 15 Oct 2013
Image Analyst
on 15 Oct 2013
Info on tables: http://blogs.mathworks.com/loren/2013/09/10/introduction-to-the-new-matlab-data-types-in-r2013b/
Or you can use the uitable() function. Not sure which you want.
Youssef Khmou
on 15 Oct 2013
Like @Image Analyst said, its working correctly, the cause may be some stored variables with same names, use clear before running the code :
clear all,
L=1.;
....
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!