1. Limited time only! Sign up for a free 30min personal 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!

I think my program is complete What happen to this line? u(i)=sin(pi

  1. Oct 16, 2013 #1
    1. The problem statement, all variables and given/known data
    I think my program is complete.. What happen to this line? u(i)=sin(pi*x(i)); ??


    2. Relevant equations

    n=10;
    c1=0;
    c2=0;
    k= 0.0025;
    L=1;
    h=0.1;
    alpha=1;
    T=0.025;
    n=L/h;m=T/k;
    lambda =alpha*k/(h^2);
    z=0:h:L;
    disp('______________________________________________')
    fprintf(' t x = ')
    fprintf('%4.2f ',z)
    fprintf('\n')
    disp('____________________________________________ _')
    fprintf('% 5.4f ',0)
    % Compute the values of u at t=0
    for i=1:n+1
    u(i)=sin(pi*x(i));
    fprintf('%10.6f ',u(i))
    end
    fprintf('\n')
    % Compute the values of u t=jk, k=1,2,...,m
    for j=1:m
    t=j*k;
    fprintf('% 5.4f ',t)
    for i=1:n+1
    if (i==1)
    y(i)=c1;
    elseif (i==n+1)
    y(i)=c2;
    else
    y(i)=(1-2*lambda)*u(i)+lambda*(u(i+1)+u(i-1));
    end;
    fprintf('%10.6f ',y(i))
    end;
    fprintf('\n')
    u=y;
    end;

    3. The attempt at a solution
    There might be error somewhere. Please help me to locate it :(
     
  2. jcsd
  3. Oct 16, 2013 #2
    this is a matlab program
     
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: I think my program is complete What happen to this line? u(i)=sin(pi
Loading...