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.

Extracting data from a 2D contour plot in Matlab

Please login with a confirmed email address before reporting spam

Hello,

I have a 2D contour plot (Cut plane>2D plot group) in Matlab that I obtained through livelink, and I want to do some analysis on its data. The 2D cut plane goes through total acoustic pressure in my 3D model.

From what I understand, in order to get that pressure data I need to run in matlab:

[Ac_P] = mphinterp(model,{'acpr.p_t'},'dataset','cpl1');

What I am getting as a result of that is a 6x14685 matrix which when plotted as a contour looks like a real mess, and nowhere close to the plot I exported to Matlab...

Anything I am doing wrong here?

Thanks in advance!


1 Reply Last Post 21 feb 2011, 20:49 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 21 feb 2011, 20:49 GMT-5
Well, I went through the test problem presented in the Livelink users guide. I loaded "heat_convection_2d.mph" from model library. I set up cut line (0.2, 0) - (0.2,1) [Plot Group2 in my case] and exported data along it to Matlab:

model = ModelUtil.model('heat2D');
figure(1)
mphplot(model,'pg2','rangenum',1)
[y,T] = mphinterp(model,{'y','T'},'dataset','cln1');
iy=~isnan(y);
iT=~isnan(T);
y=y(iy); T=T(iT);
figure(2)
plot(y,T);

But Data plotted with Matlab does not match what I've plotted with Comsol (see attached closeup graphs).

Any idea why?

Thanks in advance
Well, I went through the test problem presented in the Livelink users guide. I loaded "heat_convection_2d.mph" from model library. I set up cut line (0.2, 0) - (0.2,1) [Plot Group2 in my case] and exported data along it to Matlab: model = ModelUtil.model('heat2D'); figure(1) mphplot(model,'pg2','rangenum',1) [y,T] = mphinterp(model,{'y','T'},'dataset','cln1'); iy=~isnan(y); iT=~isnan(T); y=y(iy); T=T(iT); figure(2) plot(y,T); But Data plotted with Matlab does not match what I've plotted with Comsol (see attached closeup graphs). Any idea why? Thanks in advance

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.