1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab cannot Produce graph

  1. Oct 14, 2013 #1
    1. The problem statement, all variables and given/known data
    Hello there. I ran a matlab program and i cant produce any graph. Please help me


    2. Relevant 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')


    3. The attempt at a solution
    The program works but i cant produce any graph. I think there are little mistake somewhere.. :( pls help me
     
  2. jcsd
  3. Oct 14, 2013 #2

    Office_Shredder

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I think your problem is this line here

    which should have a u(i,1) instead of a U(i,1)
     
  4. Oct 14, 2013 #3
    Thank you so much :) really appreciate it :)
    1 more thing
    how can i tabulate data from the graph?
     
  5. Oct 14, 2013 #4

    Office_Shredder

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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.
     
  6. Oct 14, 2013 #5
    ok :) i will post a new question
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Matlab cannot Produce graph
  1. For the Graph (Replies: 7)

  2. Cannot simplify (Replies: 4)

Loading...