Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
function using cramers rule

Subject: function using cramers rule

From: steve

Date: 10 Apr, 2004 12:10:46

Message: 1 of 7

Hello,

I have spent several hours trying to write a function using cramer's
rule. Unfortunatly, I can't use any short cuts or built in functions
matlab already has. It has to be a three by three matrix with inputs
A and B and out puts X1,X2,and X3. Does anyone have any samples I
could study or suggestions for me?? Thanks for any help, I'm not
looking to copy anyones work I want to learn how to do it, just needs
some guidance or direction to go in Thanks.

Steve Dunn

Subject: function using cramers rule

From: Duane Hanselman

Date: 10 Apr, 2004 12:19:09

Message: 2 of 7

steve wrote:
>
>
> Hello,
>
> I have spent several hours trying to write a function using
> cramer's
> rule. Unfortunatly, I can't use any short cuts or built in
> functions
> matlab already has. It has to be a three by three matrix with
> inputs
> A and B and out puts X1,X2,and X3. Does anyone have any samples I
> could study or suggestions for me?? Thanks for any help, I'm not
> looking to copy anyones work I want to learn how to do it, just
> needs
> some guidance or direction to go in Thanks.
>
> Steve Dunn

Can you use the MATLAB function det()? If so, your problem is very
simple to solve; otherwise you will have to create a function to
compute determinants as well. Since you are only doing the three by
three case, you should be able to write the determinant explicitly.

This smells like a homework problem, which usually doesn't go over
well here.

Subject: function using cramers rule

From: Steve Dunn

Date: 10 Apr, 2004 12:21:45

Message: 3 of 7

Duane Hanselman wrote:
>
>
> steve wrote:
>>
>>
>> Hello,
>>
>> I have spent several hours trying to write a function using
>> cramer's
>> rule. Unfortunatly, I can't use any short cuts or built in
>> functions
>> matlab already has. It has to be a three by three matrix with
>> inputs
>> A and B and out puts X1,X2,and X3. Does anyone have any
samples
> I
>> could study or suggestions for me?? Thanks for any help, I'm
not
>> looking to copy anyones work I want to learn how to do it, just
>> needs
>> some guidance or direction to go in Thanks.
>>
>> Steve Dunn
>
> Can you use the MATLAB function det()? If so, your problem is very
> simple to solve; otherwise you will have to create a function to
> compute determinants as well. Since you are only doing the three by
> three case, you should be able to write the determinant explicitly.
>
> This smells like a homework problem, which usually doesn't go over
> well here.

Can not use det()

Subject: function using cramers rule

From: steve

Date: 10 Apr, 2004 12:51:01

Message: 4 of 7

Duane Hanselman wrote:
>
>
> steve wrote:
>>
>>
>> Hello,
>>
>> I have spent several hours trying to write a function using
>> cramer's
>> rule. Unfortunatly, I can't use any short cuts or built in
>> functions
>> matlab already has. It has to be a three by three matrix with
>> inputs
>> A and B and out puts X1,X2,and X3. Does anyone have any
samples
> I
>> could study or suggestions for me?? Thanks for any help, I'm
not
>> looking to copy anyones work I want to learn how to do it, just
>> needs
>> some guidance or direction to go in Thanks.
>>
>> Steve Dunn
>
> Can you use the MATLAB function det()? If so, your problem is very
> simple to solve; otherwise you will have to create a function to
> compute determinants as well. Since you are only doing the three by
> three case, you should be able to write the determinant explicitly.
>
> This smells like a homework problem, which usually doesn't go over
> well here.

I have the four A,A1,A2,A3 determinants figured out in proper format
as far as a11*(a22*a23-a32*a23)etc I need help in naming the function
ie y=what to use the all the determinants that I have already
written?

Thanks for your assistance,
Steve

Subject: function using cramers rule

From: Duane Hanselman

Date: 10 Apr, 2004 12:52:48

Message: 5 of 7

steve dunn wrote:

>
> Can not use det()

So, start with code that computes the determinant of a general 3 by 3
matrix. If you don't know how to do this, look it up. Computation of
the determinant can be found in lots of places. You may even find an
explicit expression for the determinant of a 3 by 3 matrix.

After than you need to call the determinant 4 times. Once to get the
determinant of the original matrix A. Then find the determinant of
the matrix that results when you replace the j-th column of A with
the right hand side vector in your equations to be solved. The ratio
of these determinants gives you x(1), x(2), and x(3).

If the above does not make sense to you, then you are not yet in a
position to think about solving the problem using MATLAB--you need to
learn the underlying academic material first. Only after that does it
make sense to think about using MATLAB.

Duane

Subject: function using cramers rule

From: steve

Date: 10 Apr, 2004 13:14:44

Message: 6 of 7

Duane Hanselman wrote:
>
>
> Steve dunn wrote:
>
>>
>> Can not use det()
>
> So, start with code that computes the determinant of a general 3 by
> 3
> matrix. If you don't know how to do this, look it up. Computation
> of
> the determinant can be found in lots of places. You may even find
> an
> explicit expression for the determinant of a 3 by 3 matrix.
>
> After than you need to call the determinant 4 times. Once to get
> the
> determinant of the original matrix A. Then find the determinant of
> the matrix that results when you replace the j-th column of A with
> the right hand side vector in your equations to be solved. The
> ratio
> of these determinants gives you x(1), x(2), and x(3).
>
> If the above does not make sense to you, then you are not yet in a
> position to think about solving the problem using MATLAB--you need
> to
> learn the underlying academic material first. Only after that does
> it
> make sense to think about using MATLAB.
>

Duane thanks for your reply,

I have already figured out the the A and x1,x2,x3 determinants by
using cramers rule of substituting the B of A X = B into the 1st, 2nd
and 3rd row respectively or ith jth and kth row. I know how to solve
the equations and have already written out all the four equations for
solving x1,x2,x3 by using A1/A, A2/A, A3/A. I keep getting an input
A argument not defined when running the program? This is directing me
to my function = line? Any suggestions?
Thanks again for your assistance.

Steve
> Duane

Subject: function using cramers rule

From: Steven Lord

Date: 12 Apr, 2004 09:17:21

Message: 7 of 7

steve wrote:

*snip*

> Duane thanks for your reply,
>
> I have already figured out the the A and x1,x2,x3 determinants by
> using cramers rule of substituting the B of A X = B into the 1st, 2nd
> and 3rd row respectively or ith jth and kth row. I know how to solve
> the equations and have already written out all the four equations for
> solving x1,x2,x3 by using A1/A, A2/A, A3/A. I keep getting an input
> A argument not defined when running the program? This is directing me
> to my function = line? Any suggestions?
> Thanks again for your assistance.

If your code isn't too long post it, the error message you receive, and the
way you call it to the group so we can take a look.

Also one additional resource that you may want to bookmark for future use:

http://www.mathworks.com/support/tech-notes/1200/1207.html

--
Steve Lord
slord@mathworks.com

Tags for this Thread

No tags are associated with this thread.

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.

Contact us