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:
Solving matrix coefficients iteratively

Subject: Solving matrix coefficients iteratively

From: Chris McCorquodale

Date: 7 Jan, 2011 09:41:05

Message: 1 of 8

Hi,

does anyone know of any functions that will solve the coefficients of a matrix iteatively. I cant seem to find any in the help. I have a large, non square matrix and I want to take each coefficient and use it to solve a complex equation by means of iteration .

What I am currently doing, is using fzero() on the maximum value from the matrix, while I think this is ok I would rather do it on all the coefficients.

If anyone could help here, that would be great! Thanks in advance,

Chris

Subject: Solving matrix coefficients iteratively

From: Torsten Hennig

Date: 7 Jan, 2011 09:52:22

Message: 2 of 8

> Hi,
>
> does anyone know of any functions that will solve the
> coefficients of a matrix iteatively. I cant seem to
> find any in the help. I have a large, non square
> matrix and I want to take each coefficient and use it
> to solve a complex equation by means of iteration .
>
> What I am currently doing, is using fzero() on the
> maximum value from the matrix, while I think this is
> ok I would rather do it on all the coefficients.
>
> If anyone could help here, that would be great!
> Thanks in advance,
>
> Chris

The problem you are trying to solve is not clear
from your description above.
Please try again.

Best wishes
Torsten.

Subject: Solving matrix coefficients iteratively

From: Chris McCorquodale

Date: 7 Jan, 2011 11:15:05

Message: 3 of 8

Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <2064831700.18092.1294393972987.JavaMail.root@gallium.mathforum.org>...
> The problem you are trying to solve is not clear
> from your description above.
> Please try again.
>
> Best wishes
> Torsten.

My apologies. Basically I have a matrix [A] of size 1x168 and I want to take each coefficient in that matrx and use it in the formula Y*(N).^b + Z*(N).^c - A = 0, where Y, b, Z and c are all known.

I want matlab to return matrix [N] with each coefficient of N being a number relating to the corresponding coefficient of A by the equation above.

I am currently using function fzero() on the maximum value of of matrix A and this (I believe) returns a minimum value for N. However I want to check this by doing a function like this to the entire matrix A so I can see the corresponding N values.

Does that make more sense?

Thanks,

Chris

Subject: Solving matrix coefficients iteratively

From: Torsten Hennig

Date: 7 Jan, 2011 11:45:23

Message: 4 of 8

> Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote
> in message
> <2064831700.18092.1294393972987.JavaMail.root@gallium.
> mathforum.org>...
> > The problem you are trying to solve is not clear
> > from your description above.
> > Please try again.
> >
> > Best wishes
> > Torsten.
>
> My apologies. Basically I have a matrix [A] of size
> 1x168 and I want to take each coefficient in that
> matrx and use it in the formula Y*(N).^b + Z*(N).^c -
> A = 0, where Y, b, Z and c are all known.
>
> I want matlab to return matrix [N] with each
> coefficient of N being a number relating to the
> corresponding coefficient of A by the equation above.
>
> I am currently using function fzero() on the maximum
> value of of matrix A and this (I believe) returns a
> minimum value for N. However I want to check this by
> doing a function like this to the entire matrix A so
> I can see the corresponding N values.
>
> Does that make more sense?
>
> Thanks,
>
> Chris

x0 = 1.0;
For j = 1:n
as = a(1,j);
n(1,j) = fzero(@(x)f(x,as,Y,Z),x0);
end

function y = f(x,as,Y,Z)
y = Y*x^b + Z*x^c - as ;

Best wishes
Torsten.

Subject: Solving matrix coefficients iteratively

From: Chris McCorquodale

Date: 7 Jan, 2011 12:23:04

Message: 5 of 8

Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <178587791.18425.1294400753572.JavaMail.root@gallium.mathforum.org>...
> x0 = 1.0;
> For j = 1:n
> as = a(1,j);
> n(1,j) = fzero(@(x)f(x,as,Y,Z),x0);
> end
>
> function y = f(x,as,Y,Z)
> y = Y*x^b + Z*x^c - as ;
>
> Best wishes
> Torsten.

Thanks very much for this Torsten. I think I understand it - may well get back to you!

Subject: Solving matrix coefficients iteratively

From: Torsten Hennig

Date: 7 Jan, 2011 12:40:17

Message: 6 of 8

> > Torsten Hennig <Torsten.Hennig@umsicht.fhg.de>
> wrote
> > in message
> >
> <2064831700.18092.1294393972987.JavaMail.root@gallium.
>
> > mathforum.org>...
> > > The problem you are trying to solve is not clear
> > > from your description above.
> > > Please try again.
> > >
> > > Best wishes
> > > Torsten.
> >
> > My apologies. Basically I have a matrix [A] of
> size
> > 1x168 and I want to take each coefficient in that
> > matrx and use it in the formula Y*(N).^b + Z*(N).^c
> -
> > A = 0, where Y, b, Z and c are all known.
> >
> > I want matlab to return matrix [N] with each
> > coefficient of N being a number relating to the
> > corresponding coefficient of A by the equation
> above.
> >
> > I am currently using function fzero() on the
> maximum
> > value of of matrix A and this (I believe) returns
> a
> > minimum value for N. However I want to check this
> by
> > doing a function like this to the entire matrix A
> so
> > I can see the corresponding N values.
> >
> > Does that make more sense?
> >
> > Thanks,
> >
> > Chris
>
> x0 = 1.0;
> For j = 1:n
> as = a(1,j);
> n(1,j) = fzero(@(x)f(x,as,Y,Z),x0);
> end
>
> function y = f(x,as,Y,Z)
> y = Y*x^b + Z*x^c - as ;
>
> Best wishes
> Torsten.

Sorry, of course, b and c also have to be supplied in f:

x0 = 1.0;
For j = 1:n
as = A(1,j);
N(1,j) = fzero(@(x)f(x,as,Y,Z,b,c),x0);
end

function y = f(x,as,Y,Z,b,c)
y = Y*x^b + Z*x^c - as ;

Best wishes
Torsten.

Subject: Solving matrix coefficients iteratively

From: Steven_Lord

Date: 7 Jan, 2011 14:30:44

Message: 7 of 8



"Chris McCorquodale" <c.mccorquodale@axon-cable.co.uk> wrote in message
news:ig6sjp$lvm$1@fred.mathworks.com...
> Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message
> <2064831700.18092.1294393972987.JavaMail.root@gallium.mathforum.org>...
>> The problem you are trying to solve is not clear
>> from your description above.
>> Please try again.
>>
>> Best wishes
>> Torsten.
>
> My apologies. Basically I have a matrix [A] of size 1x168 and I want to
> take each coefficient in that matrx and use it in the formula Y*(N).^b +
> Z*(N).^c - A = 0, where Y, b, Z and c are all known.

If b and c are nonnegative integers, you can use ROOTS instead of Torsten's
FZERO suggestion. [FZERO is an iterative method, and the direct ROOTS
method may be faster. Test and see.] If they aren't, I think FZERO is the
right approach.

As another possible solution you could, if you have Symbolic Math Toolbox,
try solving this directly for N symbolically and then substituting in your
vector A, but there may not be a closed-form solution and even if there was
it will likely be pretty complicated.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlab.wikia.com/wiki/FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Solving matrix coefficients iteratively

From: Chris McCorquodale

Date: 10 Jan, 2011 08:10:21

Message: 8 of 8

> If b and c are nonnegative integers, you can use ROOTS instead of Torsten's
> FZERO suggestion. [FZERO is an iterative method, and the direct ROOTS
> method may be faster. Test and see.] If they aren't, I think FZERO is the
> right approach.
>
> As another possible solution you could, if you have Symbolic Math Toolbox,
> try solving this directly for N symbolically and then substituting in your
> vector A, but there may not be a closed-form solution and even if there was
> it will likely be pretty complicated.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlab.wikia.com/wiki/FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Thanks for your answer steve, with the equation I have though N cannot be solved directly, it has to be iterative.

The way Torsten has shown seems to be fine. Thanks again.

Tags for this Thread

No tags are associated with 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