This s-function solves Riccati equations in Simulink without calling the Matlab interpreter, it is FAST and usable with Real Time Workshop.
Specifically, the s-function is a level-2 gateway that calls several FORTRAN routines written by Arnold and Laub in the early eighties and publicly available under the cascade sublibrary of netlib. FORTRAN code is included in the Readme file, along with further instructions on how to compile and link the s-function.
Giampiero Campa, October 2002 and January 2009
Riccardo Bevilacqua & Jason Hall, NPS Spacecraft Robotics Lab, October 2008
@burak ergocmen, have you solved the problem. I'm also having the same problem here. Did u solve it?
>> mex sfun_lqrysim.c *.o
after that error occurs :
Error using mex
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2014a/win64.
ı am new about that . When i download MinGW from sourceforge , there is no file like g77.exe. anybody help pls
Can it solve ARE to find Kalman filter gain?
Instead of use the command eval('! g77 -c *.f') in matlab, try to compile the *.f files directly in windows cmd command line. In my case the eval command was not generating the *.o files.
Go to the cmd and find the path where your *.f files are. Then compile using the command : g77 -c *.f
Like this you will generate the *.o files and then you could use :
mex sfun_lqrysim.c *.o
I´m wondering why the matlab compiler cannot find the functions writen in fortran, that are used in the sfunction. I´m using mex sfun_lqrysim.c but it doesn´t work. Those functions are not found, even though I have compiled them with g77 compiler. I´m getting this errors:
Creating library C:\Users\SAMIRA~1\AppData\Local\Temp\mex_ug7vuD\templib.x and object C:\Users\SAMIRA~1\AppData\Local\Temp\mex_ug7vuD\templib.exp
sfun_lqrysim.obj : error LNK2019: unresolved external symbol creg_ referenced in function mdlOutputs
sfun_lqrysim.obj : error LNK2019: unresolved external symbol msub_ referenced in function mdlOutputs
sfun_lqrysim.obj : error LNK2019: unresolved external symbol mlineq_ referenced in function mdlOutputs
sfun_lqrysim.obj : error LNK2019: unresolved external symbol save_ referenced in function mdlOutputs
sfun_lqrysim.obj : error LNK2019: unresolved external symbol madd_ referenced in function mdlOutputs
sfun_lqrysim.obj : error LNK2019: unresolved external symbol xty_ referenced in function mdlOutputs
sfun_lqrysim.obj : error LNK2019: unresolved external symbol mmul_ referenced in function mdlOutputs
sfun_lqrysim.obj : error LNK2019: unresolved external symbol symprd_ referenced in function mdlOutputs
sfun_lqrysim.mexw64 : fatal error LNK1120: 8 unresolved externals
Do you have any idea where is the problem?
I need the code for investigation purpuses at my university so i would be very pleased if someone can help me.
I can't seem to mex it in Matlab 2010. It fails when linking ... some unresolved symbols in scaleg.o
Unfortunately some other code that I have only works on 2010 ..
contact author is not working, yet. They know about it.
Concerning my problem: I have to compile it first, yes? G77 isn't part of minGW, but GFortran is. It compiles your *.f-files without comment or error, but the mex command cannot use the *.o-files. Matlab is r2007b. Error message is
File ... unknown section /4.
Matlab is r2007b
Hello Mr. Campa,
sorry about any inconvenience: "Contact Author" is not working, somehow.
I tried using your lqrsim with realtimeworkshop, added the source-directory like explained in the readme-file but still got the following error when compiling:
OPUS MAKE: Don't know how to make 'sfun_lqrysim.o03'. Stop.
Do I have to download the g77 compiler, as you explained for mex-files?
Please help me!
Hello Dr. Campa,
Thanks for your excellent work. I have one question: does this subroutine support solving discrete algebraic riccati equations? The Matlab command LQRY can do this for discrete system, but after I check your code, it seems that it doesn't have this option for discrete time system. Thanks.
Very good in Matlab 2007b. As you code, obviously keep in mind that Q needs to be a real symmetric positive semi-definite matrix and R needs to be a real symmetric positive definite matrix. Furthermore, if R is ill-conditioned, this block will not compute the gain properly. Conversely, Matlab's LQRY function can still compute the gain matrix even with an ill-conditioned R matrix. Very good block though.
Works very well on Matlab 2007b or older, but does not work on 2008.
How could I add this application to Matlab
sorry, but it needs improvement.
ich grade brauche ihn, danke!!!
Thank You Mr. Giampiero Campa . It works perfectly and saves time.
it is very useful for non mathematicians doing research in control theory.........
Hi. I´m Paul from Portugal.
I´ve no words to describe your excelent work.
Thank you Mr. Giampiero Campa
Fully converted to BSD License
Many thanks to Jason Hall and Riccardo Bevilacqua for your excellent job in enabling native matrices inputs to the block and
This version works with MATLAB 7.6 (R2008a), uses native matrix signals, is re-mexable on every platform, and is better integrated with real time workshop (Thanks Jason & Riccardo).
Recompiled mex files with matlab 7.1 so that everything works fine with newer versions requiring the .mexw32 extension. The .dll files are retained to the benefit users working with versions prior to 7.1, other users may delete them.
Changed info.xml file to avoid annoying messages within the last matlab versions.
Move it to simulink utilities.
Renamed everything lowercase
The file info.xml has been updated.
Instructions on how to compile with The Real Time Workshop have been added.
The fortran subfunctions have been
Win cash prizes and have your live script featured on our websiteLearn more
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.