How to copy data from a 1 x 1 double timeseries to a 1 D Lookup Table in Matlab

Viewed 296

I have been asked to look at a Matlab project. I'll link sceenshots to clarify the problem. I need to create a 1 D Lookup table with the data from a 1 x 1 double timeseries from another model that has been supplied. One problem is that there are a lot of data points (12500). Is it possible to copy these points across without having to drag the mouse down over the whole 12500 points? Someone has actually tried this dragging the mouse over all the points method and said it didn't work anyway, but I don't really want to try it myself, as it would be way to cumbersome for my liking, even if it did work.

Here is an example of what the 1 x 1 double timeseries looks like (just using 5 points instead of 12500 for simplicity's sake):

1 x 1 double timeseries

Here is the model with the 1D look up table highlighted in blue at the left:

1D loookup table in Matlab model

Here is what the 1-D lookup table looks like when opened:

Contents of 1-D lookup table

Any insight appreciated.

I've worked out how to copy the data from the timeseries table (actually from the input to this, which is a 1 x 1 struct), but he problem is that the values have no commas between them and the 1-D lookup table requires commas.

Note that the problem has now been solved using Excel, although not by the method I was trying to make work in the question. An answer has been posted which may work, but I'm not sure if i will go to the trouble of attempting to implement it or not at this stage. However, if need be and all being well, I will either do that or delete the question.

2 Answers

You can import a look-up table object (Simulink.LookupTable-object) from both, the MATLAB workspace or directly from Excel.

If you want to automate it, it basically comes down to these two points: "

  • Open the model containing the lookup table block and in the Modeling tab, select Model Settings.
  • In the Model Properties dialog box, in the Callbacks tab, click PostLoadFcn callback in the model callbacks list.

... the next time you open the model, Simulink® invokes the callback and imports the data. "

After a little thought I feel like the answer is actually fairly trivial: it just can't be done. The input field of the look up table just can't hold 12500 points, most of which have 9 or so decimal places, so there's no way to do this.

This isn't to say there's no way to put the data into the model: this can be done using Excel.

Related