User login


You are here

How to write the transfer function of mechanic systems in C language?

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!


If you are happy with crappy looking code then I would suggest trying

 mcc -c myfile

You can find more information at

My personal perefernece has been to write a new c version based on the Matlab version.

-- Biswajit 



Temesgen Markos's picture

Hi Biswajit,

Welcome back, you have been missed in this forum! 

Zhigang Suo's picture

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.

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


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

Also look at

and the main pages at and

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 


Subscribe to Comments for "How to write the transfer function of mechanic systems in C language?"

Recent comments

More comments


Subscribe to Syndicate