Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.
Create interpolation function using LiveLink with Matlab
Posted 21.05.2020, 01:12 GMT-4 Interfacing, LiveLink for MATLAB, Parameters, Variables, & Functions 1 Reply
Please login with a confirmed email address before reporting spam
Hi everyone,
I would like to create a user-defined interpolation function using LiveLink with Matlab.
Here is what I do (in Matlab):
model.component('comp1').func.create(int2, 'Interpolation'); model.component('comp1').func(int2).set('funcname','my_func'); model.component('comp1').func(int2).label('my_func_label'); model.component('comp1').func(int2).set('argunit', 's'); model.component('comp1').func(int2).set('fununit', 'Pa');
I know there are three methods to feed data to the interpolation function: Result table, file and local table. I would prefer to use the local table, so I do, which is very tedious:
model.component('comp1').func(int2).setIndex('table', t1, 1, 0); model.component('comp1').func(int2).setIndex('table', value1, 1, 1); model.component('comp1').func(int2).setIndex('table', t2, 2, 0); model.component('comp1').func(int2).setIndex('table', value2, 2, 1); model.component('comp1').func(int2).setIndex('table', t3, 3, 0); model.component('comp1').func(int2).setIndex('table', value3, 3, 1); ... ... The question: Is there a way to write the entire 2D-array or 2x1 vectors to the table? Since I need to do this for many interpolation functions (on the order of 100s) and for every time step in the simulation (on the order of 1000s), there will be a lot of resulting calls. Alternatively, I guess I could first write the data to files, but then I would have to create 100s of files first to read from.
Any help and suggestions would be appreciated,
Theo