Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Possible to use contraints with fsolve?

Subject: Possible to use contraints with fsolve?

From: dm

Date: 6 Jan, 2011 10:02:04

Message: 1 of 5

I have problem which I, at least, can't solve analytically. I have a known, complex 2-by-2-by-M matrix A, and a known 2-by-2-by-M matrix T, both symmetric, and want to find a complex 2-by-2-by-M matrix W such that A = W*T*W^T, or equivalently, minimize the residual r = A-W*T*W^T.

I've tried using

function f = myfun(x,A,T)
f = A-x*T*x.';
end

with

x0 = [0.9+1i*randn*1e-2 10+10i*; 1e-2+1i*randn 2+1i*2]; % random guess close to what is physically expected
opts = optimset('display','iter','maxiter',10000,'maxfunevals',100000);
[x fval] = fsolve(@(x) myfun(x,Apt,Tpt),x0,opts);

inside a loop, since I have 2-by-2-by-M matrices.

However, I experience that even though the residual gets very small, the values found by fsolve doesn't really end up giving a good estimate.

So the question is if I can do anything to i.e. include some constraints here, i.e. say - real(x0(1,1)) < 1
- real(x0(1,2)) > 10

and so on.

Best regards,

dm

Subject: Possible to use contraints with fsolve?

From: dm

Date: 6 Jan, 2011 10:13:04

Message: 2 of 5

I see I forgot to mention some part of the problem. The A and T matrices are measured S-parameters of some connections. The A matrix represents the cascaded connection of two devices, separated by the connection T. Since S-parameters can't be cascaded, I transform them to ABCD parameters, which can be multiplied by each other, hence A = WTW^T.

The residual I get when using fsolve is small when comparing the ABCD parameters (r = A-x*T*X.'), however, the residual of the S-parameters of W is quite bad.

For now I have only used a set of simulated S-parameters for both A, T and W, so I can check how close the estimate actually can get. Since the estimate for the simulated parameters is so bad, I can't use this for the measured data. But as mentioned, I assume I do something wrong in MATLAB, and hope someone can point something out for me. :)

-dm

Subject: Possible to use contraints with fsolve?

From: John D'Errico

Date: 6 Jan, 2011 12:00:21

Message: 3 of 5

"dm" wrote in message <ig43us$83q$1@fred.mathworks.com>...
> I have problem which I, at least, can't solve analytically. I have a known, complex 2-by-2-by-M matrix A, and a known 2-by-2-by-M matrix T, both symmetric, and want to find a complex 2-by-2-by-M matrix W such that A = W*T*W^T, or equivalently, minimize the residual r = A-W*T*W^T.
>

I'm interested. How do you define symmetry for a 2x2xM matrix,
at least where M will be greater than 1? (I can handle the case
for M == 1.)

I'm also interested in how you plan on doing the required matrix
multiplies. Your function simply writes it as a standard multiply
using * , but that won't work quite as well for general M, at least
in my version of MATLAB.

John

Subject: Possible to use contraints with fsolve?

From: dm

Date: 6 Jan, 2011 13:30:20

Message: 4 of 5

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <ig4asl$3qt$1@fred.mathworks.com>...
> "dm" wrote in message <ig43us$83q$1@fred.mathworks.com>...
> > I have problem which I, at least, can't solve analytically. I have a known, complex 2-by-2-by-M matrix A, and a known 2-by-2-by-M matrix T, both symmetric, and want to find a complex 2-by-2-by-M matrix W such that A = W*T*W^T, or equivalently, minimize the residual r = A-W*T*W^T.
> >
>
> I'm interested. How do you define symmetry for a 2x2xM matrix,
> at least where M will be greater than 1? (I can handle the case
> for M == 1.)
>
> I'm also interested in how you plan on doing the required matrix
> multiplies. Your function simply writes it as a standard multiply
> using * , but that won't work quite as well for general M, at least
> in my version of MATLAB.
>
> John

What I meant by symmetric is that for every m in [1,M], each 2-by-2 matrix A(:,:,m) is equal to A(:,:,m).' (and the same for each 2-by-2 matrix T(:,:,m)).

I also thought of doing the required operations within a loop, so I have something like

for m = 1:M
    [x_m fval] = fsolve/other function(@(x) myfun(x,A(:,:,m),T(:,:,m)),x0,opts);
end

where A(:,:,m) and T(:,:,m) now both are 2-by-2, and x0 is some initial guess for the m'th 2-by-2 matrix W(:,:,m), and opts are the options used for the iterative solver/other function.

This is probably not the best solution I guess, but I don't have a very large M (201 at most), and I can afford to do the looping.

dm

Subject: Possible to use contraints with fsolve?

From: dm

Date: 7 Jan, 2011 22:42:05

Message: 5 of 5

It turned out that lsqnonlin did the job fairly easy and good, so I think I can say problem solved. :)

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us