How to extract data of one solution from multiple solutions?
2 次查看(过去 30 天)
显示 更早的评论
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]);
Here is the solutions of an implicit function. How can I extract the x and y data of the upper line only?
0 个评论
采纳的回答
Star Strider
2023-12-13
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]);
X = Uyp.XData(:);
Y = Uyp.YData(:);
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)
The clusterdata function is in the Statistics and Machine Learning Toolbox.
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



