From: Samuel Alfredsson on 19 Jan 2010 08:34 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!
From: Michael on 20 Jan 2010 20:45 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(a)mathworks.com> wrote in message <hj4ccc$fum$1(a)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!
From: Samuel Alfredsson on 21 Jan 2010 08:00 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(a)mathworks.com> wrote in message <hj8bj2$9od$1(a)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(a)mathworks.com> wrote in message <hj4ccc$fum$1(a)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!
From: Arnaud Miege on 22 Jan 2010 05:17 "Samuel Alfredsson" <samuel.alfredsson.nospam(a)mathworks.com> wrote in message news:hj9j56$ef2$1(a)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(a)mathworks.com> wrote in message > <hj8bj2$9od$1(a)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(a)mathworks.com> wrote in >> message <hj4ccc$fum$1(a)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
|
Pages: 1 Prev: Matlab Compiler Error Next: double to long int type change in Mex |