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.

how to calculate an expression for multiple values

Please login with a confirmed email address before reporting spam



HI,

I am currently working with the classical PDE mode: Helmholtz equation. I've already obtained some values but now I am interested in manipulating these results. What I want to do is to calculate the following expression:

abs(u)*cos(arg(u)-2*pi*frec*time)

for different values of the "time" variable.

The other terms of the expression mean:

abs(u)= absolute value of the dependent variable (of the PDE system)
arg(u) =phase angle of the dependent variable (of the PDE system)

pi and frec constant values defined in "global definitions" tab.

I know that it is possible to do it manually (defining the expression for a specific value of "time" and plotting it) but the point is I need to obtain at least 300 images (in other words, I need to calculate the expression for 300 different values of the variable "time").

I do not know how to use the Comsol interface to set up a loop that allows me to obtain (and save) the 300 images. I've been also trying to manipulate the script in Matlab (just because it is easier to define loops) but I have some problems with saving and plotting images.

The problems are:

1) I am not able to plot any figure because the mphplot function does not work. When I use it, I always obtain the same problem:

"C\comsol40a\mli\mphplot.p" not recognizable as a P-file

2) I am also not able to export the image using the export function

model.result.export('img1').set('pngfilename', 'C:\\Documents and Settings\\Usuario\\Desktop\\resolution\\picture.png');

In this case Matlab does not show any error but it does not create the "picture.png" file.

I am working with the latest Comsol version 4.0a and Matlab 7.4.0 (R2007a).

I would strongly appreciate any idea or tip because I am really stuck on it.

Thank you very much

Cristina













1 Reply Last Post Dec 21, 2010, 6:55 a.m. EST
COMSOL Moderator

Hello Dejan Grabovickic

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 21, 2010, 6:55 a.m. EST
Did you solve it?

I would like to do the same with three different plots at 4 interpolated times.

maybe it is easier to plot whatever you want in a figure then use the matlab-function saveas(handle,'dir/filename.png')
Did you solve it? I would like to do the same with three different plots at 4 interpolated times. maybe it is easier to plot whatever you want in a figure then use the matlab-function saveas(handle,'dir/filename.png')

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.