- https://in.mathworks.com/help/matlab/ref/semilogx.html
- https://in.mathworks.com/help/map/ref/polyxpoly.html
"polyxpoly" doesn't intersect lines correctly
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Josh Wolstenholme
am 13 Jul. 2022
Beantwortet: Ayush
am 28 Sep. 2023
I have some grain size data plotted in a semilogx plot and would like to find out the cumulative percentages for different abundance levels. To do this I have been using "polyxpoly" but the intesection points don't align where I'd expect

In terms of the code used to produce the intersects:
intersect_x = 0.0005:0.0005:0.255;
intersect_y(1:510) = 0.84;
for x = 1:height(wolman.s1_us)
date = datestr(wolman.s1_us.Time(x),'dd-mm-yyyy');
semilogx(grain_size,wolman.s1_us{x,:},"DisplayName",date,"LineWidth",lW);
hold on
[xi(x),yi(x)] = polyxpoly(grain_size,wolman.s1_us{x,:},intersect_x,intersect_y);
scatter(xi,yi,"DisplayName",date)
end
line3 = yline(0.84,'-',yLineLabels(3),"DisplayName",yLineLabels{3});
Any help on this would be greatly appeciated!
0 Kommentare
Akzeptierte Antwort
Ayush
am 28 Sep. 2023
Hey Josh,
I understand that you are facing an issue with finding the cumulative percentages for different abundance levels based on grain size data plotted in a “semilogx” plot. You have been using the "polyxpoly" function to find the intersection points, but they do not align as expected.
For reproducing the exact issue at my end, code is required.
Meanwhile, you can convert the data to linear scale before using “polyxpoly” and then convert the resulting intersection points back to the logarithmic scale as the “polyxpoly” function operates on linear coordinates and may not give accurate intersection points when used with logarithmic scales. Here’s an example of how you can modify your code:
intersect_x = 0.0005:0.0005:0.255;
intersect_y = 0.84 * ones(size(intersect_x));
for x = 1:height(wolman.s1_us)
date = datestr(wolman.s1_us.Time(x), 'dd-mm-yyyy');
semilogx(grain_size, wolman.s1_us{x, :}, 'DisplayName', date, 'LineWidth', lW);
hold on
% Convert to linear scale for intersection calculation
linear_grain_size = 10.^grain_size;
linear_data = 10.^wolman.s1_us{x, :};
% Calculate intersection points in linear scale
[linear_xi, linear_yi] = polyxpoly(linear_grain_size, linear_data, intersect_x, intersect_y);
% Convert intersection points back to logarithmic scale
xi = log10(linear_xi);
yi = log10(linear_yi);
scatter(xi, yi, 'DisplayName', date);
end
line3 = yline(0.84, '-', yLineLabels(3), 'DisplayName', yLineLabels{3});
For more information on “semilogx” plot and “polyxpoly”, refer to MathWorks documentation link below:
Hope this information helps!
Regards,
Ayush Goyal
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!