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 iteratively

Subject: Solving iteratively

From: Chris McCorquodale

Date: 22 Dec, 2010 16:30:22

Message: 1 of 4

Hi,

I was wondering if someone could give me advice on iterative solvin in matlab? Basically, I have an equation in the form;

x = y*N^b + z*N^c

where x,y,z,b,c are known constants. I dont believe this can be solved algebraically but is there any way (by means of functions etc) matlab can solve it iteratively?

Thanks,

Chris

Subject: Solving iteratively

From: Sean de

Date: 22 Dec, 2010 17:11:20

Message: 2 of 4

"Chris McCorquodale" wrote in message <iet92u$gvb$1@fred.mathworks.com>...
> Hi,
>
> I was wondering if someone could give me advice on iterative solvin in matlab? Basically, I have an equation in the form;
>
> x = y*N^b + z*N^c
>
> where x,y,z,b,c are known constants. I dont believe this can be solved algebraically but is there any way (by means of functions etc) matlab can solve it iteratively?
>
> Thanks,
>
> Chris

doc fzero

Subject: Solving iteratively

From: Chris McCorquodale

Date: 23 Dec, 2010 08:53:04

Message: 3 of 4

> doc fzero

Hi, Thanks for pointing me in the right direction. I am struggling to get it to work though...in the doc it says:

% function f = myfun(x,c)
% f = cos(c*x);

so I write:

but when I try anything like that it comes up with "??? function f=myfun(x,d) Error: Function definitions are not permitted in this context."
Any ideas?
If I can get past this, would I define my function as:

function f = myfun(N,x,y,z,b,c)
f = y*N^b +z*N^c -x ?

where N is the only unknown?

Thanks,

Subject: Solving iteratively

From: Chris McCorquodale

Date: 23 Dec, 2010 09:17:22

Message: 4 of 4

"Chris McCorquodale" wrote in message <iev2lg$s4r$1@fred.mathworks.com>...
> > doc fzero
>
> Hi, Thanks for pointing me in the right direction. I am struggling to get it to work though...in the doc it says:
>
> % function f = myfun(x,c)
> % f = cos(c*x);
>
> so I write:
>
> but when I try anything like that it comes up with "??? function f=myfun(x,d) Error: Function definitions are not permitted in this context."
> Any ideas?
> If I can get past this, would I define my function as:
>
> function f = myfun(N,x,y,z,b,c)
> f = y*N^b +z*N^c -x ?
>
> where N is the only unknown?
>
> Thanks,


Hi ignore that last bit, I have figured it out by doing:

N=fzero(@(N) Y*(N).^b + Z*(N).^c - X,300);

It would appear that this function will only work for one individual value,however. Is there any way to compute it for the coefficients of a matrix?

The matrix i have is size 3116x1 so dont fancy typing each one individually!

Thanks,

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