Skip to main content

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

Submitted by Xianfeng Ye on

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!

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

Wed, 05/07/2008 - 08:27 Permalink

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 

 

Wed, 05/07/2008 - 21:46 Permalink