0
votes

I'm using the simulink block From Workspace to read in some audio data provided by a script. I have formatted the data in a matrix with 2 columns, the first is the timestamp and the second is the data.

In the configuration paramaters, I have specified Fixed-Step and Discrete solver. The Start time and Stop also need to be configured manually and don't seem to come from the data.

Also, in the From Workspace block configuration, I need to specify the sample time (1/44100) or I get a warning if I specify -1, to inherit from the data and then get strange sample times.

So, how can I get simulink to use only the sample times in the matrix and use the first and last timestamps as the start and stop time of the simulation?

1
Are you wanting to use non-uniform sample times? If not, I'm not sure I understand why the method you described won't work. Might want to post a pic of the model as well.macduff
I want the model to use the timestamps in the matrix and the data associated with each timestamp. I don't want interpolation by any method to happen, because the timestamps are not exactly at the 44.1 khz rate. Mathworks says I must specify the step in the source block, so what's the point of having timestamps in the matrix?Chuck Carlson
Hum, perhaps specifying non-uniform steps will force simulink to use the timestamps in the matrix. Looking at that now.Chuck Carlson

1 Answers

2
votes

You should be able to do what you want by doing the following:

Firstly note that your problem is by definition not fixed step, hence you cannot use a fixed-step solver, which by definition is ... fixed-step. You must use a variable step solver.

Assuming your (2 column) input data is called simin then set the start and stop times to be simin(1,1) and simin(end,1) respectively.

In your From Workspace block set the sample time to be 0 (which should have been the default). Also de-select the Interpolate data option; and set "Form the output after final data value by:" to zero (you won't be using anything past the end of your data set so this should be OK.

Then you need to tell the solver to take additional steps to those that it would naturally want to take. Do this on the Data Import/Export pane of the Model Configuration Parameters. Near the bottom of the pane there is a selection box and an edit box for doing this. Note however that this does not prevent the solver from taking steps at other time points, it just forces it to take additional steps at the times you specify. But because you have your From WOrkspace block to not interpolate this shouldn't be a problem either. You should put simin(:,1) in here so that the solver is guaranteed to take steps at the time points in your input data.

Note that if you want an input block that only samples at the time points in the simin time vector then the only way to do this is to write an S-function that uses the mdlGetTimeOfNextVarHit method to tell the solver what the next sample time (for this block) should be.