How to get finer data sampling?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Songlin Yue
le 13 Déc 2023
Commenté : Star Strider
le 13 Déc 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 commentaires
Réponse acceptée
Star Strider
le 13 Déc 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Smoothing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




