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.

Data From A Cut Line With MATLAB Livelink

Please login with a confirmed email address before reporting spam

The below post is related to an archived discussion


Hello,

I am having a similar experience as Pierre Guilleme (linked above), but with an acoustics model. I wish to export the imaginary component of acoustic pressure along a cut line to MATLAB and am finding some sort of jitter (supplementary points as Pierre calls them) in my MATLAB data. Two figures are attached for reference.

My model: Frequency Domain: An idealized 3D pipe acoustics model straight out of a textbook (no crazy boundaries, etc). A Cut Line has been defined along the center axis of the pipe. Using a Line Graph in COMSOL, I can easily plot imaginary pressure the expected smooth curve.

In MATLAB, I am using the command

  data = mphinterp(model,{'imag(acpr.p_t)'},'dataset','cln1','solnum',1);

to retrieve the values for the first solution of my frequency sweep.

What are these extraneous points? Is there a more efficient way to export this data into MATLAB?

Regards,

Michael Rouleau



2 Replies Last Post 22 févr. 2019, 13:36 UTC−5
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 21 févr. 2019, 03:56 UTC−5
Updated: 6 years ago 21 févr. 2019, 04:05 UTC−5

Interp doesn't always produce results in the order they appear in the geometry

Try this:

[p,s]=mphinterp(model,{'imag(acpr.p_t)' 'cln1x'},'dataset','cln1','solnum',1);
plot(s)

You'll see that the arc length is not increasing.

Do this instead:

[ss,idx]=sort(s);
plot(ss,p(idx))
-------------------
Lars Gregersen
Comsol Denmark
Interp doesn't always produce results in the order they appear in the geometry Try this: [p,s]=mphinterp(model,{'imag(acpr.p_t)' 'cln1x'},'dataset','cln1','solnum',1); plot(s) You'll see that the arc length is not increasing. Do this instead: [ss,idx]=sort(s); plot(ss,p(idx))

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 22 févr. 2019, 13:36 UTC−5

Lars,

Your response was extremely helpful. It makes perfect sense now - thank you very much!

Michael Rouleau

Lars, Your response was extremely helpful. It makes perfect sense now - thank you very much! Michael Rouleau

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.