How to get finer data sampling?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Songlin Yue
am 13 Dez. 2023
Kommentiert: Star Strider
am 13 Dez. 2023
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.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 13 Dez. 2023
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
Uyp = fimplicit(Uy,[0 1.2 -80*pi/180 100*pi/180], 'MeshDensity',5E+3);
h = Uyp.XData;
y = Uyp.YData % 11845 Data Pairs
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)]})
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Smoothing 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!




