Blogger Widgets

How do you display the tridiagonal of a matrix?

How do you display the tridiagonal of a matrix?
=====================================
 
Of one that is randomly generated in number and size in MATLAB? I already have the program to show the upper triangle and lower triangle, but I am having trouble with the tridiagonal.


Answer:

I dont know what is this tridiagonal matrix and how to programe in Math lab:

But here  ARE  some things that i found To be helpful:

BASICS:
=============

In linear algebra, a tridiagonal matrix is a matrix that has nonzero elements only in the main diagonal, the first diagonal below this, and the first diagonal above the main diagonal.

*********************Click Here for more.***********************************

My C++   Code To Print  The  Main Diagonal Elements  ,The First Diagonal Below This and  the  First Diagonal Above the main diagonal  :
=====================================================================================

#include <iostream>
using namespace std;
int main()
{
    int a=0,b=0;
    cout<<"Enter the order of the  matrix  A  \n\nNumber of Rows : ";
    cin>>a;
    cout<<"\nNumber of Columns : ";
    cin>>b;
    cout<<endl;
    int matrixA[a][b];
    cout<<"Enter the matrix Elements "<<endl;
    for(int m=0; m<a; m++)
    {

        for(int n=0; n<b; n++)
        {
            cout<<"A ("<< m+1 <<" , "<<n+1<<" ) =";
            cin>>matrixA[m][n];
            //cout<<",";
        }
        cout<<endl;
    }
//////////////////////// Printing main diagonal !
    for(int r=0; r<a; r++)
    {
        for(int s=0; s<b; s++)
        {
            if(r+1==s+1)
            {
                cout<<matrixA[r][s]<<endl;
            }


        }
    }

    ////////////////////////////// Printing Daigonal Before main daigonal

    cout<<"Element Before The Diagonal : "<<endl<<endl;

    for(int r=0; r<a; r++)
    {
        for(int s=0; s<b; s++)
        {
            if(r+1==s)
            {
                cout<<matrixA[r][s]<<endl;
            }
        }
    }

//////////////////////////////Printing Daigonal After main daigonal

    cout<<"Element After The Diagonal : "<<endl<<endl;

    for(int r=0; r<a; r++)
    {
        for(int s=0; s<b; s++)
        {
            if(r==s+1)
            {
                cout<<matrixA[r][s]<<endl;
            }
        }
    }
}

IMPORTANT:
===============================================================

You can use this Logic to get the elements to  suit  Your equations in Diagonal Matrix  !
   (I dont know what you equation to use)


DOUBTS
===========

Please post your doubts in this blog for anymore Help !! 




2 comments:

  1. Yahoo Email Support is available for all yahoo email users who visit at our page for the email support toll free number 0800-014-8929.
    yahoo help

    ReplyDelete
  2. Yahoo Customer Support Phone Number 0800-014-8929.
    yahoo phone number

    ReplyDelete