function using cramers rule

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply ndunn (5) 4/10/2004 4:10:46 PM

See related articles to this posting


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
Reply masteringmatlabSPAMNOT (103) 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
Reply 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?

Thanks for your assistance,
Steve
0
Reply 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
Reply masteringmatlabSPAMNOT (103) 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.
>

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
0
Reply ndunn (5) 4/10/2004 5:14:44 PM

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


0
Reply slord (13688) 4/12/2004 1:17:21 PM
comp.soft-sys.matlab 203517 articles. 529 followers. Post

6 Replies
125 Views

Similar Articles

[PageSpeed] 19


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

rules for using functions as basis vectors
I am trying to establish some rules to use a triad of functions as a triad of basis vectors (i.e., Frenet-Seret formalism). I have achieved most of the desired functionality but I can not get Mathematica to properly expand dot products across parantheses. Here is my code. (* define the tangent vector of the curve r[u] *) r /: D[r[u_], u_] := t[u]; (* define the dot product relations between the triad vectors *) {t /: t[u_].t[u_] := 1, t /: t[u_].n[u_] := 0, t /: t[u_].b[u_] := 0, n /: n[u_].t[u_] := 0, n /: n[u_].n[u_] := 1, n /: n[u_].b[u_] := 0, b /: b[u_].t[u_] := 0, b /: b[u...

rules for using functions as basis vectors #2
Thanks for the help but I'm hesitant to alter the attributes of Dot. Also, it is not the orderless aspect of Dot that gives me my main difficulty. I do not know how to specify the necessary rules. Here is an updated version of my code. (* here are the rules for dot products between the basis elements *) {t /: t[u_].t[u_] := 1, t /: t[u_].n[u_] := 0, t /: t[u_].b[u_] := 0}; {n /: n[u_].t[u_] := 0, n /: n[u_].n[u_] := 1, n /: n[u_].b[u_] := 0}; {b /: b[u_].t[u_] := 0, b /: b[u_].n[u_] := 0, b /: b[u_].b[u_] := 1}; (* here are the relations between derivatives of the basis elemen...

Cramer's rule using LinearAlgebra package?
Using the older linalg package, I could implement Cramer's rule, given a matrix A and vector by (for example): > A1:=copyinto(b,copy(A),1,1); > det(A1)/det(A); But I can't work out how to do something similar with the newer LinearAlgebra package. For example: > A1:=A; > A1[1..4,1]:=b; (for a 4x4 system). But this changes both A1 and A, so that > Determinant(A1)/Determinant(A); produces 1. If I assign A1:=copy(A) the same thing happens. Clearly I want to write the vector b into a column of a copy of A, without changing the original matrix A. S...

Transform list of numbers into pure functions using replace rule
Hello, I'm developed a program to invert satellite observations into geophysical variables such as forest biomass. One of the input parameters are the errors in the observation channels which can be either constant or a function. To be consistent the program expects all errors to be functions but they can also be constant functions e.g. if the error is 4 then the input parameter is "4&". I've however hit a problem with the replacement rule that allows me to transform all input errors into a function. The following works as expected in that constants in the li...

Calculating local maximum: how to use 'peaks' function, or which other function to use?
Hello, I've been trying to run that program: http://www.owlnet.rice.edu/~elec431/projects96/digitalbb/formantscode.html Shortly, the goal is to locate local maximums of a graph named 'h' and plotted as semilogy(f,abs(h)). It was defined: w = hamming(length(x)); % x is the signal f = w.*fs/(2*pi); % fs is the sampling rate of x Next, 'h' is calculated. Local maximums of 'h' are located with this part of code: [floc,fmag] = peaks(abs(h)); allfmnts = f(floc); However, it returns an error: ??? Subscript indices must either...

Use getdate function in a own Function
Hi, I have written a stored proc with some temporary tables and also used a getdate() in my stored proc. When i try to call the sproc the error is that we can only use extended sprocs or function inside a sproc. Now if try to write the stored proc directly inside a fuction ie copy paste after changing my temp tables to tables the problem is , i get a error invalid use of getdate in sproc.What do i do to get something for my results inside a table. Thanks in advance. RVG Care to post your code here? If you are using GetDate() as a default value for an input parameter you may see an error simil...

Function to use GA functions
I was wanting to use the GA toolbox to do the following: 1 Select a a combnation of various funtions; and 2 select the best settings for each funtion, to provide the highest objective function value subject to a validation data set being used where the 'best results' are compared and validated against thje results acheived with the validation dataset. Has someone done a similar exercise to this? Adam ...

how to use this function in s-function???
Hello! I update my matlab version to release 14 but i don't understand how to use this function in simulink. My simulink model has a S-Function box with the name sgdm. It has in input a mux with 11 inputs and it's output are only one. i compiled sgdm with "mcc -m sgdm" but it doesn't run. can you explain me the procedure to do this. the help doesn't helps me at all and the examples aren't really clear :s i also tried the s-function builder but i don't know how it functions. my function is this one. is it good prepared to transform in s function? thanks ...

Using a function within a function
Hi, Is it possible to declare a function within a function? I intend to use QUAD to evaluate the integral where the function to be evaluated is: lambda*(exp(-lambda*x). Do I have to write a separate function m-file for defining the integrand? Ant wrote: > > > Hi, > Is it possible to declare a function within a function? > > I intend to use QUAD to evaluate the integral where the function to > be evaluated is: > > lambda*(exp(-lambda*x). > > Do I have to write a separate function m-file for defining the > integrand? help subfunctions Thats what I got: s...

calling different functions but using one name; or assigning a function to a function?
Hi Folks, I have a program written long ago that uses a function repeatedly. The function contains an algorithm that returns a real value. Now I need to update the program with another function that is an new version of the algorithm. But I also need to maintain the ability to use the old function/algorithm at times. They would never be used at the same time. The user makes a selection of which algorithm to use. So what I am trying to do is (in pseudo code) function old_algo..... function new_algo ..... And a lot of code that is output:= algo(num1,num2,num3,num4,...

How can I use the value of a variable from a 'edit-text' callback function to a listbox callback function and use it there?
I have this code taking the value in the edit_callback function: user_entry_epochs = str2double(get(hObject,'string')); if isnan(handles.user_entry_epochs) errordlg('You must enter a numeric value','Bad Input','modal') return end Do you know how can I use user_entry_epochs in the listbox1_Callback or in button callback function? Nick Nichols wrote: > > > I have this code taking the value in the edit_callback > function: > user_entry_epochs = str2double(get(hObject,'string')); > if isnan(handles.us...

How to open a logical partition and read all of its file using windows function ReadFile() ? Question How to open a logical partition and read all of its file using windows function ReadFile() ?
Hii In my application , wanna copy all files from one partition to another partition. First I copied a file that I taken default and copied to another partition. The above operation is done by using the control code "FSCTL_GET_RETRIEVAL_POINTERS". The clusters used are read and wrote into destination volume using readfile() and writefile() windows functions. Now I gotta copy all files..... So how to proceed ....?? Thanking you. On Sat, 13 Jun 2009 09:37:42 -0700 (PDT), krish <krishnampkkm@gmail.com> wrote: >Hii > >In my applicatio...

using javascript function in php function??
Can anyone see why the checkbox in the code below doesnt get ticked when the textbox is changed ***This javascript function is called in the textbox's onchange event to check it when it is changed***** <script type="text/JavaScript"> function changed(x){ document.getElementById(x).checked=true; } </script> ******This php function determine whether the check box is shown or not (actually does more than this but ive slimed down the code) and has the javascript function in the onChange event of the echoed textbox function editable($edfield,$unedfield,$xtratext,...

error using function within a function
"find" previously appeared to be used as a function or command, conflicting with its use here as the name of a variable. A possible cause of this error is that you forgot to initialize the variable, or you have initialized it implicitly using load or eval. This is the message I get. I'm writing a new function, and use find within this new function. It seems I can't use it. Why? Thanks a lot. On 10-09-15 03:43 PM, Raymond wrote: > "find" previously appeared to be used as a function or command, > conflicting with its > use here as the name of ...

Defining functions using the output of an other function
Hi Is there any possibility in mathematica to define a function using te output of another function such as D[] oder Solve[] ? for ex. r[t_]::=Solve[y=x^2,y,x]; That actually does not work, just in order to illustrate what i am talking about^^ Thanks a lot Eckhard Hi Eckhardt, the following is one of plenty possibilities to achieve what you probably were looking for (I have replaced = by == within Solve, otherwise it doesn't make much sense): y[x_] = y /. First[Solve[y == x^2, y, x]] note that I am using Set (=) instead of SetDelayed (:=) for the defi...

Using undeclared function in template function
Consider the following program: //----------------------------------------------------------------------- template<typename T> void foo(T v) { bar(v); } void bar(int) {} int main() { foo(5); } //----------------------------------------------------------------------- gcc compiles this just fine, but clang gives an error: error: call to function 'bar' that is neither visible in the template definition nor found by argument-dependent lookup Which one is right? Juha Nieminen <nospam@thanks.invalid> writes: > gcc compiles this just fine, but clang gives ...

use a function within a new function
Hello, I have a function like: phi(a,t) = sin(2*pi*(t-a)/T' + a/T) where "T" is itself a function of "a" like here: #### Plot3D[Sin[2*\[Pi]*((t - a)/3 + a/(a + 1))], {t, 0, 9}, {a, 0, 9}, AxesLabel -> {"t", "a", "ex"}, Lighting -> False, ViewPoint -> {0, 0, 100}, PlotPoints -> 40, Mesh -> False]; #### Therefore, I would like to define T separately. Something like here: #### T[a_] = a + 1; phi[a_, t_] = Sin[2*\[Pi]*((t - a)/3 + a/T[a])]; Plot3D[phi[a, t], {t, 0, 720}, {a, 0, 720}, AxesLabel -> {"...

using using variables in built in function
Hi I would like to define this function: rsi=@(x)rsindex(close, x); in order to use the optimization toolbox. The problem is that rsindex (that is a built in function in Matlab) is the following: function rsi = rsindex(closep, nperiods) switch nargin case 1 nperiods = 14; case 2 if numel(nperiods) ~= 1 || mod(nperiods, 1) ~= 0 error('Ftseries:rsindex:NPERIODSMustBeScalar', ... 'NPERIODS must be a scalar integer.'); elseif nperiods > length(closep) error('Ftseries:rsindex:NPE...

Using function pointer in callback function
Hi, I am writing an app which encapsulates a multimedia timer. I implemented a TimerProc as static member function and a static member variable pThis as pseudo this variable to access in the static TimerProc function. timeSetEvent uses TimerProc to set the callback function. m_pCallback is a function that is passed using the SetTimerCallbackFunction. It's a function that an object owning the CMMTimer object can pass to the CMMTimer class. What I want is that every time the TimerProc function is called, the m_pCallback function is executed, resulting in the object owning the timer pr...

What function do I have to use in IDL? MATLAB corresponded function
Hi, There is a problem in searching the exact same function of MATLAB's conv() in IDL. Here is the MATLAB code: -------------------------------------------------- t=[0:90]; Kall=[0.1,0.15]; curve1=Kall(1)*t.*exp(-(Kall(2))*t); curve_ref=t.*exp(-0.5*t); hcurve1=conv(curve_ref, curve1); Ct=hcurve1(1:length(t)); plot(t, curve1, '*',t, Ct, '+') -------------------------------------------------- I want to copy this code to IDL, however, I couldn't find the function of convolution which work exactly same as MATLAB's conv(). Anybody can help me? hcurv...

problems with errodlg and other functions using msgbox function
Hello All, I have problem with GUI’s Matlab function errordlg. When I run the function errordlg for example: errordlg('File not found','File Error'); , instead of error dialog window, I get a question dialog item with text ‘Do you want to create a question dialog?’ and buttoms “yes” and “no”. This window does not work properly and throw errors when I click on it. The problem appeared few days ago; before the function worked correctly. I had also problems with other code which before worked correctly as well. I did not change any settings. I use Windows Home 7 64-bits s...

Using JA Builder on function that uses Java
When I compile my project using JA Builder in Matlab 2009a, I get the following error "Unable to determine function name or input/output argument count for function in M-file .../myscript.m" the simplest myscript.m that produces this error is javaaddpath . import MyClass So, my question is -- is it possible to compile m-scripts that dynamically load Java classes? ...

Using the GINPUT function in compiled matlab function
Hi all I have a stand alone matlab function that working with a.net window form. The matlab function gets from the .net data and plots it in the matlab figure. After call to the matlab compiled function I will have two open windows: 1) matlab figure with the plotted data 2) the .net form window My problem occurs when I�m trying to use the GINPUT matlab function. When I�m calling to the GINPUT method and press on the .NET Form before select any points on the graph then I can�t go back to the matlab figure(I get a busy mouse even the matlab figure became the active window), I think this proble...

Using output of one function in another function
Hi Guys, I have two functions in different .m files. The first function produces two values X and Y. I would like to take these two output values and use them in another function but i dont know how to make those variables available to the second function. If anyone has any idea how to do this it would be much appreciated. Kane "Kane " <kanemiller@hotmail.com> wrote in message <ije7s8$66n$1@fred.mathworks.com>... > Hi Guys, > > I have two functions in different .m files. The first function produces two values X and Y. I would like to take these two output ...