Search code examples
simulink

Extracting a vector element every timestep as the simulation runs


I have a 1D vector (y) in the workspace that has elements in it. I want these elements to amplify the magnitude of a sine-wave (through a multiplication box). How do I tell simulink to extract only one element on every timestep for the multiplication?

see attached


Solution

  • The variable used in the From Workspace block must have a specific format. Press the Help button on the block for a discussion of those formats.

    All of them require a time vector to be specified in addition to the signal value. For instance,

    t = 0:0.1:10;
    u = rand(size(t));
    tu = [t(:) u(:)];
    

    would create a suitable input that makes the block output a random value, with the value changing every 0.1s.