You are here
How to write the transfer function of mechanic systems in C language?
Mon, 2008-05-05 22:08 - Xianfeng Ye
I have finished building the transfer function model of mechanic systems in MATLAB. But now if I am going to write the model in C language, what could I do? Any hints, fire are welcome!
»
- Xianfeng Ye's blog
- Log in or register to post comments
- 13092 reads
Comments
Matlab to C
If you are happy with crappy looking code then I would suggest trying
mcc -c myfile
You can find more information at
http://www.kluid.com/mlib/viewtopic.php?t=115
My personal perefernece has been to write a new c version based on the Matlab version.
-- Biswajit
Welcome back
Hi Biswajit,
Welcome back, you have been missed in this forum!
Welcome back, Biswajit!
Dear Biswajit: So delighted to hear from you again! Hope all is well with you. You must be delighted to see the post by Andy Norris yesterday, inspired by the jClub theme led by you. We miss you and your thoughtful posts.
Matlab .m file to C code
hi Biswajit,
Thank you very much for your suggestions. I also prefer your choice, but I have no idea about that now, so I am going to try mcc first. Thanks again!
Another question is:
If I want to give one input parameter to this C code Model, do I get one output with asssumption that there are one input parameter and one output parameter in the model, while not one series of input parameters and one series of output parameters?
(I don't know why I can't post the comment, I tried several times :)
--Xianfeng Ye
Re: Matlab .m file to C code
Xianfeng,
There are several ways to pass parameters in an out of C functions. C passes arguments by value. You can see what that means by running Joe Zachary's bit of code at
http://www.cs.utah.edu/~hamlet/release/lessons/c13/examples/value/value.c#valuec
Also look at
http://www.cs.utah.edu/~hamlet/release/lessons/c13/c13/body-node2.shtml
and the main pages at
http://www.cs.utah.edu/~hamlet/ and http://www.cs.utah.edu/~hamlet/release/classes/C/contents.shtml.
To pass a set of parameters into a function you can create a struct. To get a set of modified parameters out you can send in a pointer to a struct . I prefer that approach because of the problematic memory management issues involved in creating structures inside a function and returning them.
I'm not certain how Matlab deals with that issue.
-- Biswajit