MATLAB: Creating a rectangle with 4 points rectangle Hello, I have 4 points with (x,y,z) and I want to have a closed shape which connects them. I actually want to draw 4 lines between the 4 points and make them a rectangle. Thank you for help. Best Answer plot3([2 4 4 2 2],[1 1 5 5 1], [3 3 3 3 3], '-k') % for (x,y,z)% plot([2 4 4 2 2],[1 1 5 5 1], '-k') % for (x,y) grid on axis equal Related SolutionsMATLAB: Plot double y axis, 3 curves If your data are column vector[ax,h1,h2]=plotyy(x1,y1,x2,[y2 y3])set(h1,'linestyle','none','marker','o','color','b')set(h2(1),'linestyle','-','marker','o','color','r')set(h2(2),'linestyle','-','marker','o','color','k') MATLAB: Drawing line from center to other three points Yes. You can use line() or plot();line([xCenter, xVector(1)], [yCenter, yVector(1)], 'Color', 'r', 'LineWidth', 2); line([xCenter, xVector(2)], [yCenter, yVector(2)], 'Color', 'r', 'LineWidth', 2); line([xCenter, xVector(3)], [yCenter, yVector(3)], 'Color', 'r', 'LineWidth', 2); Related QuestionHow to take a value if it goes through a straight line or another specific pointHow can i draw rectangle with line command
Best Answer