Hello,
I have a system of equations that I would like to solve using Simulink. At the moment I acheive this by, from my simulink model, calling a m-function (using the MATLAB function block) that solves the system of equations by calling fsolve. This works well but consumes a large amount of time which is why I wonder if there is any other, faster way to do this?
Is there any simulink block that could be used or perhaps a completely different strategy from that which I'm using now?
One thing is that I would like to be able to keep the equations as intact as possible so that it is easy to adjust them in the future, if needed.
Thank you in advance for your answer!
|
|
0
|
|
|
|
Reply
|
Samuel
|
1/19/2010 1:34:04 PM |
|
Hi Samuel,
Can you model your system of equations directly in Simulink? There is a non-linear solver built into Simulink that is used when it detects that you have created an algebraic loop.
See this doc for more info,
http://www.mathworks.com/access/helpdesk_r13/help/toolbox/simulink/ug/how_simulink_works15.html
HTH,
Mike
"Samuel Alfredsson" <samuel.alfredsson.nospam@mathworks.com> wrote in message <hj4ccc$fum$1@fred.mathworks.com>...
> Hello,
>
> I have a system of equations that I would like to solve using Simulink. At the moment I acheive this by, from my simulink model, calling a m-function (using the MATLAB function block) that solves the system of equations by calling fsolve. This works well but consumes a large amount of time which is why I wonder if there is any other, faster way to do this?
>
> Is there any simulink block that could be used or perhaps a completely different strategy from that which I'm using now?
>
> One thing is that I would like to be able to keep the equations as intact as possible so that it is easy to adjust them in the future, if needed.
>
> Thank you in advance for your answer!
|
|
0
|
|
|
|
Reply
|
Michael
|
1/21/2010 1:45:06 AM
|
|
Hello Michael,
Thank you for your response!
That's certainly one way of doing it but what I am after is to be able to simply write down the equations and let Simulink do the rest. The reason is that I want to be able to easily modify the equations if needed. If I model them in simulink in the way you describe it there will be some work as soon as I do the smallest of changes.
Maybe fsolve is the only way to fulfil my wishes? Basically I'm happy with that except the extensive simulation time.
Best regards,
Samuel
"Michael" <mtocci.nospam@mathworks.com> wrote in message <hj8bj2$9od$1@fred.mathworks.com>...
>
> Hi Samuel,
>
> Can you model your system of equations directly in Simulink? There is a non-linear solver built into Simulink that is used when it detects that you have created an algebraic loop.
>
> See this doc for more info,
>
> http://www.mathworks.com/access/helpdesk_r13/help/toolbox/simulink/ug/how_simulink_works15.html
>
> HTH,
>
> Mike
>
> "Samuel Alfredsson" <samuel.alfredsson.nospam@mathworks.com> wrote in message <hj4ccc$fum$1@fred.mathworks.com>...
> > Hello,
> >
> > I have a system of equations that I would like to solve using Simulink. At the moment I acheive this by, from my simulink model, calling a m-function (using the MATLAB function block) that solves the system of equations by calling fsolve. This works well but consumes a large amount of time which is why I wonder if there is any other, faster way to do this?
> >
> > Is there any simulink block that could be used or perhaps a completely different strategy from that which I'm using now?
> >
> > One thing is that I would like to be able to keep the equations as intact as possible so that it is easy to adjust them in the future, if needed.
> >
> > Thank you in advance for your answer!
|
|
0
|
|
|
|
Reply
|
Samuel
|
1/21/2010 1:00:22 PM
|
|
"Samuel Alfredsson" <samuel.alfredsson.nospam@mathworks.com> wrote in
message news:hj9j56$ef2$1@fred.mathworks.com...
> Hello Michael,
>
> Thank you for your response!
> That's certainly one way of doing it but what I am after is to be able to
> simply write down the equations and let Simulink do the rest. The reason
> is that I want to be able to easily modify the equations if needed. If I
> model them in simulink in the way you describe it there will be some work
> as soon as I do the smallest of changes.
>
> Maybe fsolve is the only way to fulfil my wishes? Basically I'm happy with
> that except the extensive simulation time.
>
> Best regards,
> Samuel
>
> "Michael" <mtocci.nospam@mathworks.com> wrote in message
> <hj8bj2$9od$1@fred.mathworks.com>...
>>
>> Hi Samuel,
>>
>> Can you model your system of equations directly in Simulink? There is a
>> non-linear solver built into Simulink that is used when it detects that
>> you have created an algebraic loop.
>>
>> See this doc for more info,
>>
>> http://www.mathworks.com/access/helpdesk_r13/help/toolbox/simulink/ug/how_simulink_works15.html
>>
>> HTH,
>>
>> Mike
>>
>> "Samuel Alfredsson" <samuel.alfredsson.nospam@mathworks.com> wrote in
>> message <hj4ccc$fum$1@fred.mathworks.com>...
>> > Hello,
>> >
>> > I have a system of equations that I would like to solve using Simulink.
>> > At the moment I acheive this by, from my simulink model, calling a
>> > m-function (using the MATLAB function block) that solves the system of
>> > equations by calling fsolve. This works well but consumes a large
>> > amount of time which is why I wonder if there is any other, faster way
>> > to do this?
>> >
>> > Is there any simulink block that could be used or perhaps a completely
>> > different strategy from that which I'm using now?
>> >
>> > One thing is that I would like to be able to keep the equations as
>> > intact as possible so that it is easy to adjust them in the future, if
>> > needed.
>> >
>> > Thank you in advance for your answer!
>
I would very much advise against the use of the MATLAB Function block, as
this calls the MATLAB engine at each time step and is therefore very
inefficient (as you have found out). As suggested, implementing the
equations using Simulink blocks would be my recommendations. If you really
want textual equations, look at Embedded MATLAB:
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/embeddedmatlabfunction.html
HTH,
Arnaud
|
|
0
|
|
|
|
Reply
|
Arnaud
|
1/22/2010 10:17:23 AM
|
|
|
3 Replies
1061 Views
(page loaded in 0.063 seconds)
Similiar Articles: Solving a system of equations in Simulink - comp.soft-sys.matlab ...Hello, I have a system of equations that I would like to solve using Simulink. At the moment I acheive this by, from my simulink model, calling a m... Time Series Equations in Simulink - comp.soft-sys.matlab ...Solving a system of equations in Simulink - comp.soft-sys.matlab ... This works well but consumes a large amount of time which is why I wonder ... Simulink Vs Matlab Diff. Equations. - comp.soft-sys.matlab ...Solving a system of equations in Simulink - comp.soft-sys.matlab ... Someone is able to modify that in order it can solve a system and not a single equation? ... solving algebraic loop - comp.soft-sys.matlabSolving a system of equations in Simulink - comp.soft-sys.matlab ... solving algebraic loop - comp.soft-sys.matlab Solving a system of equations in Simulink - comp.soft ... Simulink Algebraic Loop Error Help - comp.soft-sys.matlab ...Solving a system of equations in Simulink - comp.soft-sys.matlab ... Solving a system of equations in Simulink - comp.soft-sys.matlab ... Simulink Algebraic Loop Error ... Simulating a non-linear system with embedded matlab function in ...Solving a system of equations in Simulink - comp.soft-sys.matlab ..... from my simulink model, calling a m-function (using the MATLAB function block) that solves the ... Solving of coupled partial differential equation - comp.soft-sys ...System of Partial Differential Equations: How to Solve Maxwell ... Solving Nonlinear Coupled ... Simulink Vs Matlab Diff. Equations. - comp.soft-sys.matlab ... Simulink Vs ... constraints in system of non-linear equations - comp.soft-sys ...Solving a system of equations in Simulink - comp.soft-sys.matlab ... constraints in system of non-linear equations - comp.soft-sys ... Solving a system of equations in ... How can I solve this algebraic Riccati equation within MATLAB ...Solving a system of equations in Simulink - comp.soft-sys.matlab ..... within Matlab) to solve ordinary differential equations ... algebraic equations in simulink. algebraic loop - comp.soft-sys.matlabSolving a system of equations in Simulink - comp.soft-sys.matlab ... There is a >> non-linear solver built into Simulink that is used when it detects that >> you have ... Solving a system of equations in Simulink [Matlab]Hello, I have a system of equations that I would like to solve using Simulink. At the moment I acheive this by, from my simulink model, calling a m-function (using ... Solving a system of equations in Simulink - Newsreader - MATLAB ...Hello, I have a system of equations that I would like to solve using Simulink. At the moment I acheive this by, from my simulink model, calling a m-function (using ... 7/23/2012 12:02:51 PM
|