How can i express many bezier curve in one figure?

조회 수: 5 (최근 30일)
Jin Uk Ye
Jin Uk Ye 2019년 10월 11일
답변: Geoff Hayes 2019년 10월 11일
I have function of bezier curve, like this
---------------------------------------------------------
function P=BezierCurve(CV,nPoints)
nCV=size(CV,1)
n=nCV-1;
u=linspace(0,1,nPoints)';
B=zeros(length(u),nCV);
U=zeros(length(u),nCV);
for i=0:n
B(:,i+1)=factorial(n)/(factorial(i)*factorial(n-i));
U(:,i+1)=u.^i.*(1-u).^(n-i);
end
P=B.*U*CV;
close all
CV=[0 0 0;
1 0 0;
1 1 0;
5 10 0]
CV2=[1 1 1;
3 0 1;
4 1 2;
8 10 9]
CV3=[0 100 0;
3 0 1;
4 1 2;
8 10 9]
nPoints=100;
P=BezierCurve(CV, nPoints);
figure;hold on; grid on;
% plot Bezier Curve
plot3(P(:,1), P(:,2), P(:,3),'k')
% plot Control Vertices
plot3(CV(:,1), CV(:,2), CV(:,3),'r:o')
nPoints=100;
P=BezierCurve(CV2, nPoints);
figure;hold on; grid on;
% plot Bezier Curve
plot3(P(:,1), P(:,2), P(:,3),'k')
% plot Control Vertices
plot3(CV2(:,1), CV2(:,2), CV2(:,3),'r:o')
nPoints=100;
P=BezierCurve(CV3, nPoints);
figure;hold on; grid on;
% plot Bezier Curve
plot3(P(:,1), P(:,2), P(:,3),'k')
% plot Control Vertices
plot3(CV3(:,1), CV3(:,2), CV3(:,3),'r:o')
If i execute this, is is expressed in three figures, not in one figure.
what do i need to fix to represent multipole lines in a single figure?

답변 (1개)

Geoff Hayes
Geoff Hayes 2019년 10월 11일
Jin - you call
figure;hold on; grid on;
three times and so create three figures. If you just want all the plots on a single figure, then keep the first line that does the above, and remove the last two.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by