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.

LiveLink matlab, how to plot field distributions?

Mette Marie Joergensen

Please login with a confirmed email address before reporting spam

Hi,

I am considering an optical fiber in 2D, where I calculate eigenmodes using the RF module and do a sweep of the wavelength in Matlab using a for loop. Inside the for loop I only have the parameters that changes with wavelength. The geometry does not change, and therefore I put it outside the for loop. I have the impression from the user guide that this is the way to do it. Do you agree or are there some problems related to this? It seems to find the right solution.

My problem is that I would like to plot the field distribution for every wavelength. But I cannot seem to figure it out. I have tried to create a plot group, but I get an error when setting the solnum regardless of this is done inside or outside the for loop. I have also tried with mpheval where I then have the field distrbution as a data set, and plot it with mphplot. Also this is not optimal, since I cannot see the geometry structure, put on a colorbar or remove the mesh from the plot.

Does anyone know how to do a plot when having a for loop in matlab?

Thank you in advance.

Best regards
Mette

1 Reply Last Post 16 ago 2012, 05:07 GMT-4
Mette Marie Joergensen

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 16 ago 2012, 05:07 GMT-4
If I put my entire comsol model inside the for loop in matlab, I can create a plot group and plot the field distribution. However I do not understand why this is not possible when I take parameters that do not change outside the for loop, which should decrease the computational time. Anyone have a solution?

Best regards,
Mette
If I put my entire comsol model inside the for loop in matlab, I can create a plot group and plot the field distribution. However I do not understand why this is not possible when I take parameters that do not change outside the for loop, which should decrease the computational time. Anyone have a solution? Best regards, Mette

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.