Lars Gregersen
COMSOL Employee
Please login with a confirmed email address before reporting spam
Posted:
11 months ago
2023年10月10日 GMT+2 11:00
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:
11 months ago
2023年10月10日 GMT+2 15:14
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:
11 months ago
2023年10月11日 GMT+2 08:49
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.