Back to Browse

Real-time Data Exchange and MATLAB Code Generation with ChatGPT

463 views
Feb 4, 2025
15:47

In this video, we show how to write a MATLAB script that will pull data from a csv file that was generated in Python. The Python script (from the prior video) generates data and pushes it to a csv along with a flag file (run.flag). The MATLAB script then pulls data from this csv file and deletes the run.flag file. The two programs run in parallel and exchange data back and forth using flag file to signal which program should be running. For the prior lecture video in this series, click here: https://youtu.be/nsPt84G7fxc For the next lecture video in this series, click here: https://youtu.be/VoMWjJEglHI For a playlist of all lectures for the Smart Systems course, click here: https://www.youtube.com/playlist?list=PLliuty-DnCefs098rXyVkBDAqP-oRElgw ================================================= Here is the text for the chatGPT prompts that I used in this video: Write a matlab script that receives setpoint data and a timestamp one line at a time from a file called SetPoints.csv. Each line of data represents a single day. The script should first check for the existence of a run.flag file in the current folder. If that file exists, it should take the most recent q_SP value from the SetPoints.csv file and save that as a scalar in the matlab workspace. The script should then generate a random temperature from 100 to 400 and write that number with the same timestamp to a different csv file called PlantData.csv. Once the new line has been written to the PlantData.csv file, the script should delete the run.flag file. If the run.flag file does not exist, the code should pause for 1 second and check again. The code should run until num_days of data has been written to the csv file. ================================== The Matalb code can be downloaded here: https://kodypowell.che.utah.edu/wp-content/uploads/sites/3/2025/02/mat_to_csv.zip

Download

1 formats

Video Formats

360pmp416.4 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Real-time Data Exchange and MATLAB Code Generation with ChatGPT | NatokHD