Matlab Question Help


xpack
09-20-2009, 09:35 PM
http://img30.imageshack.us/img30/9937/74000118.png

Need help with this problem, I can understand how exactly to work it, could someone help?

MPD78
09-21-2009, 07:00 AM
You will probably get more help if you post this question on this forum.

http://www.physicsforums.com/

Thanks
Matt

davekw7x
09-21-2009, 09:18 AM
http://img30.imageshack.us/img30/9937/74000118.png

Need help with this problem, I can understand how exactly to work it, could someone help?

It's simply a problem with nine equations and nine unknowns.

Here is how I might do it using a Numerical Recipes Version 3 LUdcmp object:

// Nine equations and nine unknowns
//
#include "../code/nr3.h"
#include "../code/ludcmp.h"

int main()
{
// A couple of constants to simplify matrix entry
const Doub PI = 3.14159265358979323846;
const Doub theta1 = PI*45/180;
const Doub theta2 = PI*48.81/180;

//An array used in the constructor for the matrix of coefficients
Doub m_array[81] = {
cos(theta1), 1, 0, 0, 0, 0, 0, 0, 0,
-cos(theta1), 0, 0, 1, cos(theta2), 0, 0, 0, 0,
//
// The other seven rows
//
};

//An array used in the constructor for the right-hand side vector
Doub b_array[9] = {0,0,1000,//The other six right-hand constants

MatDoub m(9, 9, m_array);
VecDoub b(9, b_array);
VecDoub x(9);

LUdcmp ludcmp(m);
ludcmp.solve(b, x);

cout << scientific;
for (Int i=0; i < x.size(); i++) {
cout << "F" << i+1 << " = "
<< showpos << x[i] << noshowpos
<< endl;
}
return 0;
}



Output

F1 = +2.828840e+03
F2 = -2.000292e+03
.
.
.


Now, in Matlab, you could try something like

%Nine equations and nine unknowns:

% A couple of constants to simplify the matrix entry:
theta1 = pi*45/180;
theta2 = pi*48.81/180;

%The matrix of coefficients
m = [
cos(theta1), 1, 0, 0, 0, 0, 0, 0, 0;
-cos(theta1), 0, 0, 1, cos(theta2), 0, 0, 0, 0;
%
% The other seven rows
%
];

%The column vector for the right-hand side
b = [0;0;1000;...the other six constants...];

%Solve the equation. x is the solution vector

x = m \ b;


% You can use printf to show the values.
% For example
for i = 1:rows(x)
printf('F%d = %+e\n', i, x(i));
end


Regards,

Dave

MPD78
09-21-2009, 09:47 AM
You will probably get more help if you post this question on this forum.

I'm never right. LOL

Thanks Dave.

Matt

davekw7x
09-21-2009, 09:53 AM
...right...
When someone indicates that he/she doesn't know where to start, sometimes seeing an example of an approach to finding a solution can help.

Even though the original post had nothing to do with Numerical Recipes, I don't mind giving a little "food for thought" from time to time (with the kind indulgence of the owner of this forum).


Regards,

Dave