Hi Khalid,
As I understand, you are unable to create timeseries data using the “to workspace” Simulink block while saving data from the sensor in the External mode. The reason for this is that the Simulink "To Workspace" block is made to capture simulation data and export it to the MATLAB workspace. By default, the block does not create a timeseries object. Instead, it exports the simulation data as a MATLAB array.
However, you can easily convert this data into a timeseries object if you need to work with it as a timeseries. Here is how you can do that:
1. Configure the "To Workspace" Block:
- Open your Simulink model.
- Locate the "To Workspace" block that you want to use to capture data.
- Double-click on the block to open its properties dialog.
2. Configure the "To Workspace" Block Options:
- In the "To Workspace" block dialog, make sure the "Save format" option is set to "Array."
- You can specify a variable name in the "Variable name" field to assign a name to the exported MATLAB variable. For example, you can name it something like ‘myData’.
3. Run the Simulation:
4. Convert the Data to Timeseries:
- After the simulation has completed, you can convert the exported data (stored in the ‘myData’ variable) into a timeseries object using MATLAB code.
You can see the below mentioned sample code for your reference:
myTimeseries = timeseries(data, time);
I hope this helps.
Regards
Amish