0
votes

I want to import a one dimentional array of the size 800000*1 into simulink from the workspace. However blocks like "Simin" require a 2-D matrix as input. Should I use another block? I get the following error when importing a vector using simin block:

Invalid variable specified as workspace input in 'G711decoder/From Workspace'. The variable is either a matrix or is a Simulink.SimulationData.Dataset object with an element containing matrix data. The matrix data must be a real, double, have two dimensions, and at least two columns. The first column must contain time values and the remaining columns the data values. Matrix values cannot be Inf or NaN.

2
Are these just constant values, or is it an input signal (time dependent). In the last case, you should also include a time vector, so simulink knows what value to take at each time step.rinkert
I only have a vector without time values. I need the simulink to import the whole samples into an arrayzahraesb
You can use a constant block, and set the value to the name of the variable you want to use, but then the data is all used at once, whereas with 'Load from workspace' the data is taken sample by samplerinkert

2 Answers

1
votes

I dont know if you are still interested in the answer. Simulink needs of a time vector, but if you just want to import a vector like: [2 12 -4 5] you just have to add a 0 at the begging:

[0 2 12 -4 5]

Is like saying that your vector only exist at time 0, you extract it from workspace use it, and then to call it again you will have to update the time on the vector, in other words the 0 becomes a 1 then a 2 then a 3 bla bla bla

0
votes

You can use constant block for that.

Here First I created a variable as sample_matris (5x5) in workspace.

sample_matris = rand(5,5);

Here is the values created in workspace.

enter image description here

Then I used constant and entered name of the variable defined in workspace.

enter image description here

You can see that I can use values defined in workspace, by using constant block in simulink. If you need specific indices of the matris, you can use selector block in Simulink.