Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

.m file to any other format conversion

Status
Not open for further replies.

SatyajitC

Newbie level 4
Joined
Jan 1, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
Can we convert .m file of matlab to any other format like hex or .c in order to download it in micro controller and use it in real time?
 

Make a C translation and a MEX-file for myfun.m:
mcc -x myfun

Make a C translation and a stand-alone executable for myfun.m:
mcc -m myfun

Make a C++ translation and a stand-alone executable for myfun.m:
mcc -p myfun

Make a C translation and a Simulink S-function for myfun.m
(using dynamically sized inputs and outputs):
mcc -S myfun

Make a C translation and a Simulink S-function for myfun.m
(explicitly calling for one input and two outputs):
mcc -S -u 1 -y 2 myfun

Make a C translation and stand-alone executable for myfun.m. Look for
myfun.m in the directory /files/source, and put the resulting C files and
executable in the directory /files/target:
mcc -m -I /files/source -d /files/target myfun

Make a C translation and a MEX-file for myfun.m. Also translate and include
all M-functions called directly or indirectly by myfun.m. Incorporate the
full text of the original M-files into their corresponding C files as C
comments:
mcc -x -h -A annotation:all myfun

Make a generic C translation of myfun.m:
mcc -t -L C myfun

Make a generic C++ translation of myfun.m:
mcc -t -L Cpp myfun

Make a C MEX wrapper file from myfun1.m and myfun2.m:
mcc -W mex -L C myfun1 myfun2

Make a C translation and a stand-alone executable from myfun1.m and myfun2.m
(using one mcc call):
mcc -m myfun1 myfun2

Make a C translation and a stand-alone executable from myfun1.m and myfun2.m
(by generating each output file with a separate mcc call):
mcc -t -L C myfun1 % yields myfun1.c
mcc -t -L C myfun2 % yields myfun2.c
mcc -W main -L C myfun1 myfun2 % yields myfun1_main.c
mcc -T compile:exe myfun1.c % yields myfun1.o
mcc -T compile:exe myfun2.c % yields myfun2.o
mcc -T compile:exe myfun1_main.c % yields myfun1_main.o
mcc -T link:exe myfun1.o myfun2.o myfun1_main.o
 

while programming microcontroller for real time applications we can access pins of microcontroller to take input from real time devices like sensors viz. PORT A^1 ,PORT A^2. In the same way,how to access hardware ports in MATLAB while programming? Is it possible ?
 

Now the sad part is this all will work only in MATLAB 7.0 of greater version. now it is very simple. the following four lines will work to give you output.

open = daqhwinfo('parallel')
DIO1 = digitalio('parallel','LPT1');
DIO2 = digitalio('parallel','LPT1');
outreg = addline(DIO1, 0:7, 0, 'out');
inreg = addline(DIO2, 0:4, 1, 'in');

outreg is the variable in which output value will be put into by MATLAB and sent to ports and inreg is port to which the input value will be saved. now the '0:7' represents 8 pins of dataport and '0:4' represents 5 pins of status port.

putvalue(DIO1.Line(2),1) puts the value to line number "2" of the DIO1 configured port and the poutput value is 1.

getvalue(OBJ) will get the input value.
 

i want to convert .m file to c or .mdl file. and want to load it on dsp kit. how it is possible. plz rep. or if i send u c.m files , can u convert it in c ??
 

Sir, I tried your commands and i successfully convert my .m file to .c, but when I failed to convert .m file to .cpp for c++.

when i run this command "mcc -p filename"

it will shows the following error,


>>mcc -p ecoli_swarm_opt
??? Error using ==> mcc
Error: No source files were specified (-? for help).

pls help me
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top