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:
Differential of non-linear problems and symbolic toolbox

Subject: Differential of non-linear problems and symbolic toolbox

From: David

Date: 25 Nov, 2009 20:08:06

Message: 1 of 3

Hi All,
I would like to solve problem of four non-linear equations with 4 unknown by Newton-Raphson's method. I understand the method since it is not difficult, but my problem is how to differentiate the equations in Matlab. So far I have been using 'syms' and then 'diff' this works perfectly and it gives me a differential of the equation. But I don't know how to use obtained equation and how to feed them by actual numbers. For example one of my functions is :

F1 = (Tin - Ts_in) * h_rad_in + (Tin - Ts_in) * h_conv_in - (Ts_in - Ts_cav_in) * 1./Rm_in;

then I derivative F1 , for example, by Ts_in, so I will get:

F1' = -h_rad_in - h_conv_in - 1/Rm_in.

and here I finish and don't know how to get the F1'. I know all the coefficients but the functions is probably still symbolic and does not substitute all symbolic variable by number, for example Rm_in by 15, etc.
I assume that there should be easy solution of this just by using some built-in matlab function, but I dont know how to turn it back to use number instead of symbols.

Another think is that h_rad_in is actually coefficient which contains also Ts_in:

h_rad_in = emis_res_in*SB*(Ts_in^4-Troom^4)/(Ts_in-Troom)

, therefore the derivation of F1' as I wrote above is probably not correct. Is in matlab possible to differentiate the function in the way that it looks what the coefficients actually contains? As far as I understand this I should not use 'syms' since it will treat the coefficient only as variable symbol.

I can of course write all the derivations of the functions manually and then just by Newton-Raphson's metnod to get all the roots correctly but I am more curious about this and would like to know it for my further work since it will be probably more complex than just 4 non-linear equations. I hope that I used correct therms and that you will understand.

Thank you for all suggestions and advices
David

Subject: Differential of non-linear problems and symbolic toolbox

From: Georgios

Date: 25 Nov, 2009 22:28:03

Message: 2 of 3

"David " <d.appelfeld@gmail.com> wrote in message <hek2r6$fff$1@fred.mathworks.com>...
> Hi All,
> I would like to solve problem of four non-linear equations with 4 unknown by Newton-Raphson's method. I understand the method since it is not difficult, but my problem is how to differentiate the equations in Matlab. So far I have been using 'syms' and then 'diff' this works perfectly and it gives me a differential of the equation. But I don't know how to use obtained equation and how to feed them by actual numbers. For example one of my functions is :
>
> F1 = (Tin - Ts_in) * h_rad_in + (Tin - Ts_in) * h_conv_in - (Ts_in - Ts_cav_in) * 1./Rm_in;
>
> then I derivative F1 , for example, by Ts_in, so I will get:
>
> F1' = -h_rad_in - h_conv_in - 1/Rm_in.
>
> and here I finish and don't know how to get the F1'. I know all the coefficients but the functions is probably still symbolic and does not substitute all symbolic variable by number, for example Rm_in by 15, etc.
> I assume that there should be easy solution of this just by using some built-in matlab function, but I dont know how to turn it back to use number instead of symbols.
>
> Another think is that h_rad_in is actually coefficient which contains also Ts_in:
>
> h_rad_in = emis_res_in*SB*(Ts_in^4-Troom^4)/(Ts_in-Troom)
>
> , therefore the derivation of F1' as I wrote above is probably not correct. Is in matlab possible to differentiate the function in the way that it looks what the coefficients actually contains? As far as I understand this I should not use 'syms' since it will treat the coefficient only as variable symbol.
>
> I can of course write all the derivations of the functions manually and then just by Newton-Raphson's metnod to get all the roots correctly but I am more curious about this and would like to know it for my further work since it will be probably more complex than just 4 non-linear equations. I hope that I used correct therms and that you will understand.
>
> Thank you for all suggestions and advices
> David

See the help file for the "subs" command. The link takes you to the Mathworks site.

http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/subs.html

Regards,
Georgios

Subject: Differential of non-linear problems and symbolic toolbox

From: David

Date: 27 Nov, 2009 06:50:18

Message: 3 of 3

Thank you Georgio, this works and it is exactly what I was looking for.
What about secont part of my thread. Does anyone knows how to derivative equation with coefficients which contains elements which should be derivative. It means that the function or command should looks through the whole document what actually the equation contains.

David



"Georgios" <gkokovid@yahoo.com> wrote in message <hekb1j$9ub$1@fred.mathworks.com>...
> "David " <d.appelfeld@gmail.com> wrote in message <hek2r6$fff$1@fred.mathworks.com>...
> > Hi All,
> > I would like to solve problem of four non-linear equations with 4 unknown by Newton-Raphson's method. I understand the method since it is not difficult, but my problem is how to differentiate the equations in Matlab. So far I have been using 'syms' and then 'diff' this works perfectly and it gives me a differential of the equation. But I don't know how to use obtained equation and how to feed them by actual numbers. For example one of my functions is :
> >
> > F1 = (Tin - Ts_in) * h_rad_in + (Tin - Ts_in) * h_conv_in - (Ts_in - Ts_cav_in) * 1./Rm_in;
> >
> > then I derivative F1 , for example, by Ts_in, so I will get:
> >
> > F1' = -h_rad_in - h_conv_in - 1/Rm_in.
> >
> > and here I finish and don't know how to get the F1'. I know all the coefficients but the functions is probably still symbolic and does not substitute all symbolic variable by number, for example Rm_in by 15, etc.
> > I assume that there should be easy solution of this just by using some built-in matlab function, but I dont know how to turn it back to use number instead of symbols.
> >
> > Another think is that h_rad_in is actually coefficient which contains also Ts_in:
> >
> > h_rad_in = emis_res_in*SB*(Ts_in^4-Troom^4)/(Ts_in-Troom)
> >
> > , therefore the derivation of F1' as I wrote above is probably not correct. Is in matlab possible to differentiate the function in the way that it looks what the coefficients actually contains? As far as I understand this I should not use 'syms' since it will treat the coefficient only as variable symbol.
> >
> > I can of course write all the derivations of the functions manually and then just by Newton-Raphson's metnod to get all the roots correctly but I am more curious about this and would like to know it for my further work since it will be probably more complex than just 4 non-linear equations. I hope that I used correct therms and that you will understand.
> >
> > Thank you for all suggestions and advices
> > David
>
> See the help file for the "subs" command. The link takes you to the Mathworks site.
>
> http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/subs.html
>
> Regards,
> Georgios

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