How to replay recorded CAN data in .trc or .csv format in Matlab/Simulink using Vehicle Network Toolbox.

18 views (last 30 days)
I used peak-system to record CAN data. I would like to use that data again in my Matlab/Simulink to analysis data, to plot graphs etc. I am aware about the Vehicle Network Toolbox, I could use it Log and Replay. But what about previously recorded data in .trc or .csv format.

Answers (1)

Riya
Riya on 31 Oct 2023
Hello Anuj Shah,
As per my understanding you want to know how to replay recorded CAN data in .TRC or .CSV format in Matlab/Simulink using Vehicle Network Toolbox.
Please note that to replay your recorded CAN data in MATLAB/Simulink using the Vehicle Network Toolbox, you would need to first import the data into MATLAB. Once the data is imported, you can use the Vehicle Network Toolbox to process and analyze the data.
Here's a simple example of how to import and replay CAN data in MATLAB:
1. Import data:
If your data is in .TRC format, you would need to convert it to a format that MATLAB can understand, such as .CSV or .MAT. If you already have .csv data, you can import it directly into MATLAB.
data = readtable('your_file.csv');
This will load your data into a table in MATLAB.
2. Create a CAN channel:
You need to establish a connection to your CAN device. Replace `'PEAK-System'`, `'PCAN_USBBUS1'` with your device's vendor and channel.
ch = canChannel('PEAK-System', 'PCAN_USBBUS1');
3. Create a message replay object:
You can create a message replay object using the `canMessageReplay` function. This function takes two arguments: a CAN channel object, and a timetable of message data.
replay = canMessageReplay(ch, data);
4. Start the replay:
You can start the replay using the `start` function.
start(replay);
Note: The Vehicle Network Toolbox currently does not support the replay of CAN FD messages.
Also remember that the specific code you need to use will depend on the format of your data and the specific CAN device you are using. Always refer to the MATLAB documentation and the documentation of your CAN device for the most accurate information.
I hope it helps.
Thanks
Riya

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!