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!

Matlab code for summation?

  1. Apr 26, 2009 #1
    i need to write this into matlab

    http://www.engin.umich.edu/class/bme456/ch10fitbiphasic/biphasfit19.gif [Broken]

    which i have done here:

    uj = (-sig/Ha)*(xj-(((2*h)/(pi^2))*((((-1)^n)/((n+1/2)^(1/2)))*sin((n+1/2)*((pi*xj)/h))*exp(((-Ha*ko)/(h^2))*((n+1/2)^2)*(pi^2)*t))));

    how do i vary n, and get the equation to sum over n=0-3? and then again from n=0-100?
    Last edited by a moderator: May 4, 2017
  2. jcsd
  3. Apr 26, 2009 #2
    Call everything inside the summation f(n)

    for i=1:4 %n from 0 to 3 case
    y(i) = f(i-1)


    for i=1:101 %n from 0 to 3 case
    y(i) = f(i-1)



    Should work
  4. May 3, 2010 #3
    I got the following error for the same equation, following your summation of f(n),
    "??? Subscript indices must either be real positive integers or

    Error in ==> scriptrun at 16

    My code:

    for i=1:3 %n from 0 to 2 case
    uj = (-sig/Ha)*(xj-(((2*h)/(pi^2))*f(n)*sin((n+1/2)*((pi*xj)/h))*exp(((-Ha*ko)/(h^2))*((n+1/2)^2)*(pi^2)*t)));

    Any advise?
  5. May 3, 2010 #4
    You're summing uj = (-sig/Ha)*(xj-(((2*h)/(pi^2))*f(n)*sin((n+1/2)*((pi*xj)/h))*exp(((-Ha*ko)/(h^2))*((n+1/2)^2)*(pi^2)*t))) that's what f(n) is. just calling that expression will give an error, I believe.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Matlab code for summation?
  1. Matlab for summation (Replies: 0)

  2. Matlab @ (Replies: 1)

  3. Summation question (Replies: 3)

  4. Summation Verification (Replies: 6)