Why isn't MATLAB producing graphs for my program?

  • Thread starter Thread starter iwan89
  • Start date Start date
  • Tags Tags
    Graph Matlab
iwan89
Messages
27
Reaction score
0

Homework Statement


Hello there. I ran a MATLAB program and i can't produce any graph. Please help me


Homework Equations


This are the program


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')


The Attempt at a Solution


The program works but i can't produce any graph. I think there are little mistake somewhere.. :( pls help me
 
Physics news on Phys.org
I think your problem is this line here

U(i,1) = sin(pi*x(i));

which should have a u(i,1) instead of a U(i,1)
 
  • Like
Likes 1 person
Thank you so much :) really appreciate it :)
1 more thing
how can i tabulate data from the graph?
 
I don't really understand your question (are you asking how to use the tabulate function in matlab?). At any rate you should make a new thread if you have a new question.
 
ok :) i will post a new question
 
Prove $$\int\limits_0^{\sqrt2/4}\frac{1}{\sqrt{x-x^2}}\arcsin\sqrt{\frac{(x-1)\left(x-1+x\sqrt{9-16x}\right)}{1-2x}} \, \mathrm dx = \frac{\pi^2}{8}.$$ Let $$I = \int\limits_0^{\sqrt 2 / 4}\frac{1}{\sqrt{x-x^2}}\arcsin\sqrt{\frac{(x-1)\left(x-1+x\sqrt{9-16x}\right)}{1-2x}} \, \mathrm dx. \tag{1}$$ The representation integral of ##\arcsin## is $$\arcsin u = \int\limits_{0}^{1} \frac{\mathrm dt}{\sqrt{1-t^2}}, \qquad 0 \leqslant u \leqslant 1.$$ Plugging identity above into ##(1)## with ##u...

Similar threads

Back
Top