Results 1 to 2 of 2

Math Help - Generating Tridiagonal matrix right hand values on Matlab

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    15

    Generating Tridiagonal matrix right hand values on Matlab

    for a tridiagonal matrix, where the matrix is nxn, the right hand side is: b_i = 6/h^2*(y_i+1-2*y_i+y_i-1), i = 1...n where y_i = cos(i*h), i = 0...n+1 and h = pi/(n+1).

    Instead I just wrote the equation as b_i+1 = 6/h^2*(cos((i+2)*h) - 2*cos((i+1)*h) + cos(i*h), where h = pi/(n+1) since it seemed easier to organize.
    I want to solve the tridiagonal system and analyze what happens when n increases. But I'm not sure how to do this.

    Here's what I have so far:

    array=zeros(1,4)
    for i=1:4
    h=pi/(i+1)
    array(i)=h
    end

    array2=zeros(1,4)
    for ii=1:4
    d=6./array.^2.*(cos((i+2).*array)-2.*cos((i+1).*array)+cos(i.*array))
    array2(ii)=d
    end

    Please help. Thanks so much!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by bambamm View Post
    for a tridiagonal matrix, where the matrix is nxn, the right hand side is: b_i = 6/h^2*(y_i+1-2*y_i+y_i-1), i = 1...n where y_i = cos(i*h), i = 0...n+1 and h = pi/(n+1).

    Instead I just wrote the equation as b_i+1 = 6/h^2*(cos((i+2)*h) - 2*cos((i+1)*h) + cos(i*h), where h = pi/(n+1) since it seemed easier to organize.
    I want to solve the tridiagonal system and analyze what happens when n increases. But I'm not sure how to do this.

    Here's what I have so far:

    array=zeros(1,4)
    for i=1:4
    h=pi/(i+1)
    array(i)=h
    end

    array2=zeros(1,4)
    for ii=1:4
    d=6./array.^2.*(cos((i+2).*array)-2.*cos((i+1).*array)+cos(i.*array))
    array2(ii)=d
    end

    Please help. Thanks so much!
    Incomprehensible, please post the exact question or provide more context.

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Mathematica, how to construct a tridiagonal matrix?
    Posted in the Math Software Forum
    Replies: 3
    Last Post: August 23rd 2010, 02:38 AM
  2. Tridiagonal matrix
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: January 20th 2010, 12:43 PM
  3. tridiagonal matrix problem
    Posted in the Advanced Algebra Forum
    Replies: 2
    Last Post: September 22nd 2009, 11:39 AM
  4. sysmetric tridiagonal matrix
    Posted in the Advanced Algebra Forum
    Replies: 1
    Last Post: November 18th 2008, 10:49 AM
  5. tridiagonal matrix
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: October 26th 2008, 07:50 AM

Search Tags


/mathhelpforum @mathhelpforum