Clear Filters
Clear Filters

Good morning please help me :( badly needed

1 view (last 30 days)
How can I equate two matrices element by element suppose the other matrix is a variable matrix?
Ex:
A= [ 1,2,3;2,5,6]
B= [ a+b,a^2+b,c+a;a^2,b,c]
Then the output should Evaluate the valuez of a,b and c
I am typing A=B but that doesnt work also if I type
Y=[A==B], the output will just become
"a+b ==1"
and so on
But does not solve the values what should I do.
Thank you

Answers (2)

Torsten
Torsten on 14 Dec 2017
Symbolically, this is not possible since you have 6 equations in 3 unknowns.
Try the numeric way to get the least-squares solution for overdetermined problems:
x0=[1 2 3];
fun=@(x)[x(1)+x(2)-1,x(1)^2+x(2)-2,x(3)+x(1)-3,x(1)^2-2,x(2)-5,x(3)-6];
xsol=lsqnonlin(fun,x0)
Best wishes
Torsten.

Kevin Ryan Maravilla
Kevin Ryan Maravilla on 14 Dec 2017
Thank you very much.i'm sorry i asked incompletely, But i am referring to the cholesky method in which Symmetric Matrix will be multiplied to the product of a (lower triangular matrix and its transpose, in which a ,b,c,d,e,f are the variables)
Let A be the input symmetric matrix Let X be the product of lower triangular matrix and its . transpose
Suppose A is a 3x3 symmetric matrix : [1,2,3;2,5,6;3,6,1]
Then X is [a^2 ,ab,ac ; ab,b^2 + d^2,bc+de ;ac, bc+de ,c^2 +e^2 +f^2]
How can I compare A and X, element by element so that i will find the values of a,b,c,d,e,f I just cant type A=X it says error and it doesnt compute the values, i need to find the values of the said variables so that the output will show two matrices one is the lower triangular matrix with the values of a,b,c,d,e,f and the other one is its transpose
*we are not allowed to use chol function / built in functions
Thank you very much for your answer..

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!