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.

weird behavior in data after extracting it from COMSOL plot with LiveLink

Please login with a confirmed email address before reporting spam

Hello there,

When extracting the data points of a line plot from COMSOL with something like: data = mphplot(model,'pg37'); y_data_plot = data{1,1}{1,1}.d; I get this weird 'noise' in my data which can be seen in the Matlab plot. The attached pictures show the problem. This is a problem for my post processing as I need to determine the local maxima/minima. It seems like a numerical issue but I don't know how. Has someone seen this behavior before?

To give some background, I perform a contact study where a structure is pushed against a counter surface. The plots show the distance between the deformed configuration of the bottom domain of the structure and the counter surface.



3 Replies Last Post Oct 11, 2023, 2:49 a.m. EDT
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Oct 10, 2023, 5:00 a.m. EDT

Hi Helge

Depending on where Comsol gets its data from the order of the data may depend on the mesh and other settings.

The field data{1}{1}.t tells you the order of the data. I.e. the t-field contains two numbers (start-index end-index) for each line segment in the plot.

-------------------
Lars Gregersen
Comsol Denmark
Hi Helge Depending on where Comsol gets its data from the order of the data may depend on the mesh and other settings. The field data{1}{1}.t tells you the order of the data. I.e. the t-field contains two numbers (start-index end-index) for each line segment in the plot.

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Oct 10, 2023, 9:14 a.m. EDT

Hi Lars,

thank you for the hint! I couldn't figure out how to plot it correctly with the simplex indices so below a workaround/solution which is easy and worked for me (for anyone encountering this in the future):

you can get the correct order of the y-data in Matlab by first sorting the x-data with: [x-data_sorted,order-x] = sort(x-data); and then sorting the y-data according to the order of the x-data with: y-data_sorted = y-data(order-x);

greetings, Helge

Hi Lars, thank you for the hint! I couldn't figure out how to plot it correctly with the simplex indices so below a workaround/solution which is easy and worked for me (for anyone encountering this in the future): you can get the correct order of the y-data in Matlab by first sorting the x-data with: \[x-data\_sorted,order-x\] = sort(x-data); and then sorting the y-data according to the order of the x-data with: y-data\_sorted = y-data(order-x); greetings, Helge

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Oct 11, 2023, 2:49 a.m. EDT

Hi Helge

Plotting is easy. Just do (for lines): patch('vertices', pd{1}{1}.p', 'faces', pd{1}{1}.t'+1)

You can of course also just do this: mphplot(pd) ;-)

If you know that your data has increasing x-valees (or y-values) then you can sort the data and perform the plotting or data analysis on the sorted data. Not all data are like that. Data may have gaps and/or have x- and y-values that can't be sorted in to an increasing sequence. This is the reason mphplot return the data in the form that it does.

-------------------
Lars Gregersen
Comsol Denmark
Hi Helge Plotting is easy. Just do (for lines): patch('vertices', pd{1}{1}.p', 'faces', pd{1}{1}.t'+1) You can of course also just do this: mphplot(pd) ;-) If you know that your data has increasing x-valees (or y-values) then you can sort the data and perform the plotting or data analysis on the sorted data. Not all data are like that. Data may have gaps and/or have x- and y-values that can't be sorted in to an increasing sequence. This is the reason mphplot return the data in the form that it does.

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.