Thread Subject: defining a matrix

Subject: defining a matrix

From: Sean Douglas

Date: 14 Aug, 2009 15:49:18

Message: 1 of 3

hey guys I added a line or two of code to an mfile to define a matrix =a so I can use matrix "a" in the next mfile. It seems to come out defined, but then in the next mfile I use it comes out that a is undefined. here is what the screen it showing me. btw I also defined b in my mfile so I dont know if that will be next problem?

>> clear
>> sparsesetupmod1(8)

a =

     3 -1 0 0 0 0 0 0
    -1 3 -1 0 0 0 0 0
     0 -1 3 -1 0 0 0 0
     0 0 -1 3 -1 0 0 0
     0 0 0 -1 3 -1 0 0
     0 0 0 0 -1 3 -1 0
     0 0 0 0 0 -1 3 -1
     0 0 0 0 0 0 -1 3


b =

     2
     1
     1
     1
     1
     1
     1
     2


ans =

     3 -1 0 0 0 0 0 0
    -1 3 -1 0 0 0 0 0
     0 -1 3 -1 0 0 0 0
     0 0 -1 3 -1 0 0 0
     0 0 0 -1 3 -1 0 0
     0 0 0 0 -1 3 -1 0
     0 0 0 0 0 -1 3 -1
     0 0 0 0 0 0 -1 3

>> jacobi(a,b,3)
??? Undefined function or variable 'a'.

%%%could it me the output of the ans= at the end is screwing it up? Thanks for your time!

Subject: defining a matrix

From: TravisC

Date: 14 Aug, 2009 16:42:19

Message: 2 of 3

Is sparsesetupmod1 a function or a script? Look at the first non-comment line in the file and see if there's a function declaration.
If it's a function, you need to return the value "a", as in,

>> clear
>> [a,b] = sparsesetupmod1(8)
 
If it's a script, check to see if "a" is being cleared somewhere after it's displayed.
Good luck,
-TravisC


"Sean Douglas" <seanjdouglas@hotmail.com> wrote in message <h6411u$3v1$1@fred.mathworks.com>...
> hey guys I added a line or two of code to an mfile to define a matrix =a so I can use matrix "a" in the next mfile. It seems to come out defined, but then in the next mfile I use it comes out that a is undefined. here is what the screen it showing me. btw I also defined b in my mfile so I dont know if that will be next problem?
>
> >> clear
> >> sparsesetupmod1(8)
>

>
> >> jacobi(a,b,3)
> ??? Undefined function or variable 'a'.
>
> %%%could it me the output of the ans= at the end is screwing it up? Thanks for your time!

Subject: defining a matrix

From: Sean Douglas

Date: 14 Aug, 2009 16:54:04

Message: 3 of 3

"TravisC " <tcuprak@deleteThis.hotmail.com> wrote in message <h6445b$2r3$1@fred.mathworks.com>...
> Is sparsesetupmod1 a function or a script? Look at the first non-comment line in the file and see if there's a function declaration.
> If it's a function, you need to return the value "a", as in,
>
> >> clear
> >> [a,b] = sparsesetupmod1(8)
>
> If it's a script, check to see if "a" is being cleared somewhere after it's displayed.
> Good luck,
> -TravisC
>
>
> "Sean Douglas" <seanjdouglas@hotmail.com> wrote in message <h6411u$3v1$1@fred.mathworks.com>...
> > hey guys I added a line or two of code to an mfile to define a matrix =a so I can use matrix "a" in the next mfile. It seems to come out defined, but then in the next mfile I use it comes out that a is undefined. here is what the screen it showing me. btw I also defined b in my mfile so I dont know if that will be next problem?
> >
> > >> clear
> > >> sparsesetupmod1(8)
> >
>
> >
> > >> jacobi(a,b,3)
> > ??? Undefined function or variable 'a'.
> >
> > %%%could it me the output of the ans= at the end is screwing it up? Thanks for your time!
\
yeah, thanks a million Travis

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
thanks travis Sean Douglas 14 Aug, 2009 12:59:21
yeah Sean Douglas 14 Aug, 2009 12:59:21
defining a matrix Sean Douglas 14 Aug, 2009 11:54:04
rssFeed for this Thread

Contact us at files@mathworks.com