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.
[Solved] Evaluate and access Derived Values in Matlab Livelink
Posted 8 janv. 2021, 14:01 UTC−5 General, LiveLink for MATLAB, Results & Visualization Version 5.5 5 Replies
Please login with a confirmed email address before reporting spam
The below post is related to an archived discussion
Hello fellow COMSOLer,
If you are reading this, you are probably looking for a way to update and access some value from the Derived Values node using Matlab Livelink. After struggling to find a solution online, I figured it out by exporting my COMSOL model as a .m script and then observing how the Derived Value operations were documented. This may be useful, for example, when you run your model iteratively through Matlab Livelink and want to view the desired value after each iteration (which was my case). So here goes:
Let's suppose:
-you already have an Average operation 'av1' under Derived Values in your model.
-the results of this model are stored in the dataset 'dset7'.
-the evaluations of 'av1' are stored in the table 'tbl11'.
model.result.numerical('av1').set('data', 'dset7'); model.result.numerical('av1').set('table', 'tbl11'); model.result.numerical('av1').appendResult;
table_of_values = mphtable(model,'tbl11');
In the Matlab variable Workspace, you will find the structure "table_of_values". The values you are looking for will be inside it in the field "data".
Let's say you want to access the latest value which you just evaluated: value_of_interest = table_of_values.data(1,end)
Hope this helps. Don't know if there is a more elegant way of doing it, but far better than opening the .mph file everytime after running the model in Matlab to evaluate and check the Derived Values.