Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

COMSOL 4.1 and LiveLink MATLAB R2010b

Please login with a confirmed email address before reporting spam

Ok, I am really confused and somewhat frustrated by how difficult it seems to read results in MATLAB from a COMSOL solution.

I could easily export my result in a text file directly from COMSOL and then do calculations in Excel but that would defeat the purpose of using my calculations results back in COMSOL!

What I did in COMSOL:
- Linear Graph of a 1D Plot Group to get the temperature profile on a edge (Data Set named "Edge 2D 1") of a 2D geometry (this look like attachment #1).

What I'm trying to do: Calculate the STANDARD DEVIATION of the temperature profile on that edge (for further modification of geometric parameter to optimize it).

What I have been TRYING to do in MATLAB:
- Get the temperature values on my edge by using (after exporting my model from COMSOL to the COMSOL server):

[myTemp] = mphinterp(model, ['T'], 'dataset', 'edg1')

That doesn't work, it gives me data for half of my edge and afterwards it's all over the place (see attachment #2) (I guess I would need to sort out my values but why isn't it following the arc length?)

I also tried:

myTemp = mpheval(model, 'T', 'edim', 1, 'selection', 3)

which gives me a structure which contains my temperature data but once again my data are all scrambled up when I try to plot them (see attachment #2)

Any ideas why this is so scrambled up? I just want to calculate the Standard Deviation which shouldn't be that hard!

Where is the "LiveLink" in there? I don't see any bidirectional capabilities and surely not "seamless integration" as it was suppose to be... :(


11 Replies Last Post 29.02.2012, 11:48 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30.03.2011, 03:47 GMT-4
Hi Dominique,


What I have been TRYING to do in MATLAB:
- Get the temperature values on my edge by using (after exporting my model from COMSOL to the COMSOL server):

[myTemp] = mphinterp(model, ['T'], 'dataset', 'edg1')

That doesn't work, it gives me data for half of my edge and afterwards it's all over the place (see attachment #2) (I guess I would need to sort out my values but why isn't it following the arc length?)

I also tried:

myTemp = mpheval(model, 'T', 'edim', 1, 'selection', 3)

which gives me a structure which contains my temperature data but once again my data are all scrambled up when I try to plot them (see attachment #2)

Any ideas why this is so scrambled up? I just want to calculate the Standard Deviation which shouldn't be that hard!



I'm sorry I don't have a solution, but I have exactly the same problem with my model. I just want the data that COMSOL plots in Matlab to edit it.


Have you solved it yet?

Regards,

Peter.

Hi Dominique, [QUOTE] What I have been TRYING to do in MATLAB: - Get the temperature values on my edge by using (after exporting my model from COMSOL to the COMSOL server): [myTemp] = mphinterp(model, ['T'], 'dataset', 'edg1') That doesn't work, it gives me data for half of my edge and afterwards it's all over the place (see attachment #2) (I guess I would need to sort out my values but why isn't it following the arc length?) I also tried: myTemp = mpheval(model, 'T', 'edim', 1, 'selection', 3) which gives me a structure which contains my temperature data but once again my data are all scrambled up when I try to plot them (see attachment #2) Any ideas why this is so scrambled up? I just want to calculate the Standard Deviation which shouldn't be that hard! [/QUOTE] I'm sorry I don't have a solution, but I have exactly the same problem with my model. I just want the data that COMSOL plots in Matlab to edit it. Have you solved it yet? Regards, Peter.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30.03.2011, 11:19 GMT-4
Hi,

I'm also confronting the similar problem, confused with the postprocess.
Anyone can help?
Hi, I'm also confronting the similar problem, confused with the postprocess. Anyone can help?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30.03.2011, 11:26 GMT-4
I haven't work on that since, been busy with something else.
I will need to get back on it, so if I find out anything, I'll keep you posted.

Good luck finding your way in MATLAB "LiveLink"....
I haven't work on that since, been busy with something else. I will need to get back on it, so if I find out anything, I'll keep you posted. Good luck finding your way in MATLAB "LiveLink"....

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30.03.2011, 14:16 GMT-4
Well, the LiveLink itself isn't that hard to get to know. Just don't forget to click "File" > "Reset History" before saving your .mph files as .m file.This makes your code a lot less messy.
Well, the LiveLink itself isn't that hard to get to know. Just don't forget to click "File" > "Reset History" before saving your .mph files as .m file.This makes your code a lot less messy.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30.03.2011, 14:19 GMT-4
Yep, that's a good point (resetting the History).

But right now I'm still stuck at the point where I can modify a file that I converted into a .m file but I am not yet able to reconvert a .m into a .mph file...
Yep, that's a good point (resetting the History). But right now I'm still stuck at the point where I can modify a file that I converted into a .m file but I am not yet able to reconvert a .m into a .mph file...

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30.03.2011, 14:22 GMT-4
After modifying your model in Matlab use (not sure about the exact syntax, no COMSOL on my laptop):
model.save('myModel.mph');
After modifying your model in Matlab use (not sure about the exact syntax, no COMSOL on my laptop): model.save('myModel.mph');

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30.03.2011, 14:52 GMT-4
Yes, that's for saving it back into the COMSOL server.

My problem is:
- If I send a file through the COMSOL server from COMSOL to MATLAB, I don't know how to save that file in MATLAB as a .m file. (model.save does not allow that).

So the only way I found to have a .m file is to directly in COMSOL, save as MATLAB .m file.
Once I do that, I can open the file in MATLAB without problem and edit it BUT I can't sent it back into COMSOL nor the COMSOL server since there is no way to read a .m file into the MPH model class (if there is, I haven't found one).
Yes, that's for saving it back into the COMSOL server. My problem is: - If I send a file through the COMSOL server from COMSOL to MATLAB, I don't know how to save that file in MATLAB as a .m file. (model.save does not allow that). So the only way I found to have a .m file is to directly in COMSOL, save as MATLAB .m file. Once I do that, I can open the file in MATLAB without problem and edit it BUT I can't sent it back into COMSOL nor the COMSOL server since there is no way to read a .m file into the MPH model class (if there is, I haven't found one).

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 06.07.2011, 15:16 GMT-4
That is my question too: How to send back the edited .m file to Comsol.
That is my question too: How to send back the edited .m file to Comsol.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 11.07.2011, 08:32 GMT-4
see my thread 'convert .m to .mph'!
see my thread 'convert .m to .mph'!

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 04.10.2011, 21:59 GMT-4
Try this for getting temperature at any point from matlab m file:

Compute the temperature T at the center of the domain:
T = mphinterp(model,'T','coord',[0.3;0.5])

This command "mphinterp" has replaced "postinterp" in Comsol 3.5a. Hope this helps.
Thanks.
Try this for getting temperature at any point from matlab m file: Compute the temperature T at the center of the domain: T = mphinterp(model,'T','coord',[0.3;0.5]) This command "mphinterp" has replaced "postinterp" in Comsol 3.5a. Hope this helps. Thanks.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 29.02.2012, 11:48 GMT-5
Hi everyone,

I have a similar problem with mphinterp...

I have a 2D model, on wich I have used the Heat Transfer module in a transient study. I want to read and save the temperature evolution in a point I have defined in the center of my domain, but I don't want to call it by its coordinates. That is, I want to "call" that point by its tag.

So lets say this point is number 3. I do the following:

[Temp] = mphinterp(model,'T','Edim',0,'selection',3);

I get this error:

??? Error using ==> mphinterp at 144
Coordinate or non-solution dataset is required

I am using the COMSOL version 4.2a

Have you solved your problem? Do you have any ideas about what I am doing wrong?

Thank you!

Ana Gaspar
Hi everyone, I have a similar problem with mphinterp... I have a 2D model, on wich I have used the Heat Transfer module in a transient study. I want to read and save the temperature evolution in a point I have defined in the center of my domain, but I don't want to call it by its coordinates. That is, I want to "call" that point by its tag. So lets say this point is number 3. I do the following: [Temp] = mphinterp(model,'T','Edim',0,'selection',3); I get this error: ??? Error using ==> mphinterp at 144 Coordinate or non-solution dataset is required I am using the COMSOL version 4.2a Have you solved your problem? Do you have any ideas about what I am doing wrong? Thank you! Ana Gaspar

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.