Save sensor and measurement data in a text file

Questions about Marilou Open Devices Access (MODA)
Post Reply
yusie.rizal
Posts: 20
Joined: Thu Jun 16, 2011 8:01 am

Save sensor and measurement data in a text file

Post by yusie.rizal » Thu Oct 20, 2011 12:49 pm

Hi all,

I try to do some 'parameters estimation' for my system (ball and plate system). The idea is, I make a system, and since the dynamic equation is too complicated and nonlinear, then I want to do some 'virtual' experiment using AnyKode.

I try to inject some input and observe some output and records all data that i m interested in one text file. Then, using Matlab, I can read those data and calculate what is the estimated parameter of the system. By doing this, I believe my state space system can become more simpler.

So, the question is: how can I make a text file in Anykode?
I try to use sample c++ code (use some include file)
#include <iostream.h>
#include <fstream.h>
..
and so on.

But it seems doesnt work.

Regards,

YR

fabian
Posts: 36
Joined: Sun Jun 15, 2008 9:45 am

Re: Save sensor and measurement data in a text file

Post by fabian » Thu Oct 20, 2011 2:41 pm

Hi,

Usually i do something like that:

FILE *stream=fopen("c:\\myfile.txt","wb");
...

fprintf(stream,"MYDATA1=%d;MYDATA2=%d",i,j);

or

fputs("my string");

...
fclose(stream);

I know you can do that by using iostrem: variable>>cout but i've nener tried.

fab
Fab

yusie.rizal
Posts: 20
Joined: Thu Jun 16, 2011 8:01 am

Re: Save sensor and measurement data in a text file

Post by yusie.rizal » Fri Oct 21, 2011 12:18 pm

Thanks,

It works..

Post Reply