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.

Generating 2D plots on Livelink MATLAB

Please login with a confirmed email address before reporting spam

Hello, I am trying to use the Livelink MATLAB application for COMSOL 5.4 and I seem to have trouble generating plots and viewing plots made in my applicaiton

Are there any good resources/tutorials that are available to learn from?

EDIT: I have made some progress using the LiveLink for MatLab user guide but now I am stuck since I do not know the specific name of attrtype for the function model.result(<pgtag>).feature(<ftag>).feature.create(<attrtag>, attrtype);

I do now that I want to plot the emw.normE from my model but I do not know what that would be called.

This is my script in MATLAB so far:



1 Reply Last Post 29.10.2019, 04:59 GMT-4
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 29.10.2019, 04:59 GMT-4
Updated: 5 years ago 29.10.2019, 01:05 GMT-4

Hi Owen

Your script looks fine. Note however, that it is usually much easier to work with a model that is saved as an MPH-file since you often can load that file a lot faster than the time it takes to build the model from scratch.

As far as I can tell your script already makes a plot that plots emw.normE (since this is the default expression)!

The easiest way to learn about what commands to use when changing a setting in a model is to

  1. Open or create the model in Matlab (If you load the file using mphload or mphopen you must enable history recording. See the help text for more info)
  2. Use the command mphlaunch to open the Comsol GUI
  3. Make the changes to the model in the Comsol GUI
  4. Save the model as an M-file (e.g.: mphsave(model, 'modelfilename.m') )
  5. Open the M-file in the editor and look at the last lines of the file
  6. Copy the lines you need to your own scripts.

Alternatively, you can use mphnavigator to view and setting in a model. Once you have found a property you wish to change you can use the button "Copy set" that will copy the statement that sets the property to the clipboard.

-------------------
Lars Gregersen
Comsol Denmark
Hi Owen Your script looks fine. Note however, that it is usually much easier to work with a model that is saved as an MPH-file since you often can load that file a lot faster than the time it takes to build the model from scratch. As far as I can tell your script already makes a plot that plots emw.normE (since this is the default expression)! The easiest way to learn about what commands to use when changing a setting in a model is to 1. Open or create the model in Matlab (If you load the file using mphload or mphopen you must enable history recording. See the help text for more info) 2. Use the command mphlaunch to open the Comsol GUI 3. Make the changes to the model in the Comsol GUI 4. Save the model as an M-file (e.g.: mphsave(model, 'modelfilename.m') ) 5. Open the M-file in the editor and look at the last lines of the file 6. Copy the lines you need to your own scripts. Alternatively, you can use mphnavigator to view and setting in a model. Once you have found a property you wish to change you can use the button "Copy set" that will copy the statement that sets the property to the clipboard.

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.