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.

Exporting from Matlab back to Comsol and plotting in Comsol

Please login with a confirmed email address before reporting spam

Hello,

I want to export a variable from Matlab back into Comsol to plot it after some processing has been performed on it.

Initially I exported an electric field distribution (the x,y,z components Ex, Ey, Ez) from Comsol to Matlab. I did some calculations on it, and now want to export it back to Comsol. The original format was a 1-by-n matrix with length n equal to the number of position (x,y) pairs in the mesh (this is how Comsol exports it), and the output is still a 1-by-n matrix.

For argument's sake, let's just pretend I took that original matrix and multiplied it by 2, and now am trying to import it back into Comsol to plot. Thus all values are still in the same order, to be used with the original (x,y) points in the original mesh. If I did this in Comsol, it would obviously just be 2 ewfd.Ex, for example. But I want to do this in Matlab and export to Comsol, because I am doing more than just multiplying by 2.

How do I go about doing that? Thank you for any help you can provide.


2 Replies Last Post 2018年11月20日 GMT-5 11:41
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 2018年11月19日 GMT-5 08:20
Updated: 6 years ago 2018年11月19日 GMT-5 08:36

If you just wish to use the data for plotting then you could look at the new (in 5.4) LineData feature. Using this you can add plots to Comsol models which data aren't based on Comsol results. You'll find a description of LineData in the Programming Reference Manual.

Alternatively you can save your data in a file format that Comsol can read (e.g. using mphinterpolationfile) and import the data into an interpolation table. You can use the imported data for plotting as well as for modelling.

-------------------
Lars Gregersen
Comsol Denmark
If you just wish to use the data for plotting then you could look at the new (in 5.4) LineData feature. Using this you can add plots to Comsol models which data aren't based on Comsol results. You'll find a description of LineData in the Programming Reference Manual. Alternatively you can save your data in a file format that Comsol can read (e.g. using mphinterpolationfile) and import the data into an interpolation table. You can use the imported data for plotting as well as for modelling.

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 2018年11月20日 GMT-5 11:41

Lars,

Thanks for the response. I will try this out.

Lars, Thanks for the response. I will try this out.

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.