Search code examples
matlabsimulink

"From workspace" Simulink


Please, I am simulating a dynamic system with some inputs with real data in form of array, For example 1*16 or a matrix of 16*16 dimension stored in Matlab workspace. I have been for a long time trying to use the "From Workspace" block in Simulink.

Blockquote

My simulation Time is 1:10 Time Step:0.01

Blockquote

My Goal : is to display the content of my array or matrix element by element during my simulation.enter image description here

Thank you a lot in advance for any valuable answer.


Solution

  • Instead of manually building the struct like you did, I recommend to use a timeseries object. It will fore you to use the right data structure and gives better feedback.

    Try

    %16 timestamps matching your data size, replace with your time infomration
    time=0:.1:1.5;
    %placeholder for your data
    m=rand(1,16);
    %create timeseries
    ts=timeseries(m,time);
    

    To verify in MATLAB that your timeseries does what you want, use:

    ts.plot(); %won't output anything useful with random data.
    

    Then use ts in your from Workspace block.