creating files on raspberry pi with simulink

조회 수: 6(최근 30일)
Will 2014년 3월 23일
댓글: Marc Compere 2015년 12월 3일
Hi all,
I'm a new user to simulink and the raspberry pi, and have begun playing with the example library in simulink.
I've been trying to save to a text file on the pi using the h.openShell('ssh') command line interface.
I've been able to able to create directories and text files, however, after taking out the SD card and putting it into my desktop, I cant find these folders and files.
I'm sure this is due to my lack of knowledge as to what i'm actually doing (I apologise), could someone point me towards a method of saving data to a file and then being able to view this text file on a host computer or through simulink?
(in the long run I want to be able to run a matlab function on the pi, which will save variable data into a text file which I want to be able to read on the SD card from a PC)
Regards, Will
  댓글 수: 2
Marc Compere
Marc Compere 2015년 12월 3일
I am interested in this as well.
We need to write a file to /tmp to capture data from the running Simulink algorithm for post-processing after the test.
How can we get data in Simulink written to /tmp/myTest.txt?

댓글을 달려면 로그인하십시오.

채택된 답변

Murat Belge
Murat Belge 2014년 3월 26일
The SD card used in Rspberry Pi has two partitions. One is a FAT32 boot partition the other is an EXT partition where Linux root file system resides. When you create a file in Linux and say save it to your home folder, it goes to the EXT partition. Windows computers cannot read the EXT partition so you won't see this partition when you view the SD card contents on your Windows computer. If you were to use a Linux computer, you could view the files.
If you are creating files on the Raspberry Pi, you can actually retrieve them using the raspberrypi MATLAB command line interface:
>> h = raspberrypi
>> h.getFile('/home/pi/myfile.txt')
for example. This will retrieve the file called myfile.txt on your Raspberry Pi's SD card, and save it onto the current directory in MATLAB.
Check out the Motion Sensor Camera demo in the Simulink Support Package for Raspberry Pi. This demo actually saves the images captured from a camera to the SD card.

추가 답변(2개)

Will 2014년 3월 24일
Update - Saving from the bash cmd line is fine, but more specfically, how can I save a text file to the sd card or usb from inside a matlab model function?

Murat Belge
Murat Belge 2014년 3월 27일
Look at the demo model "raspberrypi_motion_sensor_camera". In this model, there is a block called "raspberrypi_motion_sensor_camera/Triggered Subsystem/save a snapshot". This is actually a MATLAB function for saving data to a file. Replicate / re-purpose this block for your needs.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by