f

#### function using cramers rule

```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
```
 0
ndunn (5)
4/10/2004 4:10:46 PM
comp.soft-sys.matlab 211266 articles. 19 followers. lunamoonmoon (257) is leader.

6 Replies
942 Views

Similar Articles

[PageSpeed] 49

```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.
```
 0
4/10/2004 4:19:09 PM
```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()
```
 0
ndunn (5)
4/10/2004 4:21:45 PM
```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?

Steve
```
 0
ndunn (5)
4/10/2004 4:51:01 PM
```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
```
 0
4/10/2004 4:52:48 PM
```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.
>

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?

Steve
> Duane
```
 0
ndunn (5)
4/10/2004 5:14:44 PM
```steve wrote:

*snip*

>
> 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

```
 0
slord (13689)
4/12/2004 1:17:21 PM