How to get finer data sampling?

R0 = 0.917;
h0 = 1;
n = 8;
rk = 1;
k = 1;
d = 32/180*pi;
Lv0 = sqrt(h0.^2+2*R0.^2-2*R0.^2.*cos(d));
Ld0 = sqrt(h0.^2+2*R0.^2-2*R0.^2.*cos(d+2*pi/n));
Lv = @(h,y) sqrt(h.^2+2*R0.^2-2*R0.^2.*cos(d+y));
Ld = @(h,y) sqrt(h.^2+2*R0.^2-2*R0.^2.*cos(d+y+2*pi/n));
Uy = @(h,y) k*(1-Lv0./Lv(h,y)).*sin(y+d)+rk*k*(1-Ld0./Ld(h,y)).*sin(y+d+2*pi/n);
Uyp = fimplicit(Uy,[0 1.2 -80*pi/180 100*pi/180]);
h = Uyp.XData;
y = Uyp.YData;
The above figure is the solution lines of the implicit function Uy. Here I want to extract the XData and YData, but find that there only exist 357 samping data for x and y axis. I'm wondering is there any ways of gettting a finer sampling? For example, getting 10000 data between 0 and 1.2.

 Accepted Answer

Use the 'MeshDensity' name-value pair —
R0 = 0.917;
h0 = 1;
n = 8;
rk = 1;
k = 1;
d = 32/180*pi;
Lv0 = sqrt(h0.^2+2*R0.^2-2*R0.^2.*cos(d));
Ld0 = sqrt(h0.^2+2*R0.^2-2*R0.^2.*cos(d+2*pi/n));
Lv = @(h,y) sqrt(h.^2+2*R0.^2-2*R0.^2.*cos(d+y));
Ld = @(h,y) sqrt(h.^2+2*R0.^2-2*R0.^2.*cos(d+y+2*pi/n));
Uy = @(h,y) k*(1-Lv0./Lv(h,y)).*sin(y+d)+rk*k*(1-Ld0./Ld(h,y)).*sin(y+d+2*pi/n);
Uyp = fimplicit(Uy,[0 1.2 -80*pi/180 100*pi/180]);
h = Uyp.XData;
y = Uyp.YData % 359 Data Pairs
y = 1×359
-1.3963 -1.3878 -1.3753 -1.3748 -1.3631 -1.3544 -1.3522 -1.3422 -1.3334 -1.3328 -1.3242 -1.3161 -1.3125 -1.3086 -1.3015 -1.2948 -1.2915 -1.2885 -1.2826 -1.2770 -1.2718 -1.2706 -1.2668 -1.2620 -1.2576 -1.2533 -1.2497 -1.2493 -1.2455 -1.2419
Uyp = fimplicit(Uy,[0 1.2 -80*pi/180 100*pi/180], 'MeshDensity',5E+3);
h = Uyp.XData;
y = Uyp.YData % 11845 Data Pairs
y = 1×11845
-1.3963 -1.3962 -1.3958 -1.3956 -1.3953 -1.3950 -1.3949 -1.3945 -1.3944 -1.3940 -1.3937 -1.3936 -1.3932 -1.3931 -1.3928 -1.3925 -1.3923 -1.3919 -1.3919 -1.3915 -1.3912 -1.3911 -1.3907 -1.3906 -1.3902 -1.3900 -1.3898 -1.3894 -1.3894 -1.3890
X = h(:);
Y = y(:);
XY = [X Y];
XY = rmmissing(XY);
X = XY(:,1);
Y = XY(:,2);
cidx = clusterdata(Y(:), 3);
[Ucidx,~,idx] = unique(cidx);
segments = accumarray(idx, (1:numel(idx)).', [], @(x){[X(x) Y(x)]})
segments = 3×1 cell array
{6677×2 double} { 833×2 double} {4333×2 double}
figure
hold on
for k = 1:size(segments,1)
plot(segments{k}(:,1), segments{k}(:,2), 'LineWidth',3, 'DisplayName',["Line #"+k])
end
hold off
grid
legend('Location','best')
axl = axis;
figure
plot(segments{1}(:,1), segments{1}(:,2), 'LineWidth',3)
grid
title('Upper Line Only')
axis(axl)
It still works correctly with my earlier code.
.

2 Comments

Thank you very much for your help of these 2 questions.
As always, my pleasure!
They are both interesting!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!