Get data from hardware using C and process it in MATLAB in real time

11 ビュー (過去 30 日間)
Kishore Kumar
Kishore Kumar 2021 年 10 月 8 日
I have a C program that output 10200 bytes of data by communicating with an hardware. I want to process the data in matlab, plot it and refetch new set of value and process it in realtime in a loop. I want to update the graph in realtime. How to obtain otuput of c program in matlab. I use Eclipse IDE for C programming.
What is the best way to do it?
The hardware is a FTDXX device that brings data from a sensor.

採用された回答

Tanmay Das
Tanmay Das 2021 年 10 月 13 日
Hi,
To my understanding, you want to use the outputs returned by the C code to generate plots in MATLAB. There can be two possible ways by which you can do that:
  1. You can have a C code in the system path and call it while executing the MATLAB code. You may find the documentation on Call C/C++ Code from MATLAB Code helpful if you take this approach.
  2. Another way could be to have everything inside Simulink and call the C code using MATLAB Function block. You can then connect the outputs of the block to Scope to generate graphs. You may find the documentation on Integrate C Code by Using the MATLAB Function Block helpful if you take this particular approach.

その他の回答 (1 件)

Kishore Kumar
Kishore Kumar 2021 年 10 月 18 日
編集済み: Kishore Kumar 2021 年 11 月 3 日
I found this method simpler. Just run the program using system command in matlab.
Run the code like you would do in your cmd. But to receive 10200 bytes of data as output of system function took a considerable delay. so i dumped the values of c code in to a txt file and read the text files to import in matlab. That was really faster.
EDIT:
Now I have started using the shared library provided by FTDI using MATLAB callllibrary function. It works as expected.

カテゴリ

Help Center および File ExchangeDSP Algorithm Acceleration についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by