How Do I send a variable sized array from simulink to matlab workspace (using continuous time and without altering the sample time) ?

4 visualizzazioni (ultimi 30 giorni)
I have a simulink model and inside that there is a matlab function block which outputs a variable size array. I was able to take care of it by selecting the output variable type as variable in the Port & Data Manager.
Now the To Workspace block throws me an error stating I cannot export a variable sized array. I checked several matlab community posts and tried them too, it didn't work. On top of that I tried this documentation in matlab too - Export Data to MATLAB - MATLAB & Simulink - MathWorks Benelux . It did not work.
Can you please let me know a reliable way to solve this problem ?

Risposte (2)

Poorna
Poorna il 2 Apr 2024
Modificato: Poorna il 2 Apr 2024
Hi Vignesh,
I see you want to export a variable-size output of a matlab function block to workspace as an array using "To Workspace" block. I also see that the system has a continuous sample time.
As of MATLAB R2024a, variable-size signals doesn't support continuous sample time. Also array format logging is not supported for variable-size signals as mentioned in the below documentation: https://www.mathworks.com/help/simulink/ug/variable-size-signal-basics.html
You can check the "Variable-Size Signal Limitations" section in the above link to check out the limitations of variable-size signals.
So, a possible workaround is to compute the maximum range of the the output signal and then make the signal a fixed-size signal with the maximum range as the size. Or you could discretize the sample time and log the signal in Structure/Structure with time/Timeseries using the "To Workspace" block and post process the data to make it an array.
Hope this helps.

Fangjun Jiang
Fangjun Jiang il 2 Apr 2024

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by