當我運行此代碼時:
pts= [-1 0; 0 1; 1 0; 0 -1];
xCenter = 0;
yCenter = 0;
plot(xCenter,yCenter,pts(:,1), pts(:,2),'g');
我得到這個情節:

我需要更改什么,以便我將繪制 符號,所有線條將從中心開始。
uj5u.com熱心網友回復:
只需在每對點之間添加原點
pts= [-1 0; 0 0; 0 1; 0 0; 1 0; 0 0; 0 -1];
否則你會在“ ”的端點之間跳躍,這就是為什么你會得到一個正方形的 3 個邊。
您可以使用類似的東西自動執行此操作
pts= [-1 0; 0 1; 1 0; 0 -1];
xCenter = 0;
yCenter = 0;
% Initialise the array to all be the center point
newPts = repmat( [xCenter, yCenter], size(pts,1)*2-1, 1 );
% Every other row comes from the original "pts"
newPts(1:2:2*size(pts,1),:) = pts;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/397913.html
標籤:MATLAB
