- #1
Urmi Roy
- 753
- 1
So let's say I have 2 matrices A and B. I need to solve 2 eqns involving specific elements of each matrix.
e.g. A(1)+B(2)=4; A(1)-B(2)=2.
Is there any way to do this? My efforts with Fsolve and solve have failed.
Here's what I've done so far:
function F=myfun(A,B)
F=[A(1)-B(2)-2;
A(1)+B(2)-4];
end
In the command window I typed:
>>A=ones(2,2);
>> B=ones(2,2);
>> [A,B]=fsolve(@myfun,A,B)
I even tried
[A(1),B(1)]=fsolve(@myfun,A(1),B(1))
Neither attempt worked.
e.g. A(1)+B(2)=4; A(1)-B(2)=2.
Is there any way to do this? My efforts with Fsolve and solve have failed.
Here's what I've done so far:
function F=myfun(A,B)
F=[A(1)-B(2)-2;
A(1)+B(2)-4];
end
In the command window I typed:
>>A=ones(2,2);
>> B=ones(2,2);
>> [A,B]=fsolve(@myfun,A,B)
I even tried
[A(1),B(1)]=fsolve(@myfun,A(1),B(1))
Neither attempt worked.