MATLAB: Help with vertex transformations

graphgraphingMATLABplotplottingtransformationvertex

Hello everyone, I am trying to round the corners of my "W" stencil I have created so that it is rounded at the vertices when it turns directions during the plot. Also how can i mimick the degree of the rounded angle? Thank you for any help.
clear all; close all;
trunk = 0.5; % height of each y component
aspect = 1.4; % set the aspect ratio
total_height = 2.5; % total height of letter W
total_width = (25/14);
% selecting points to move around the block
xpos = [(-125/224),-(25/28), -(75/112), -(25/56),-(25/224), (25/224), (25/56),(75/112),(25/28), (125/224),(75/224), 0, -(75/224), -(125/224)];
ypos = [0,total_height, total_height, 0.75, total_height,total_height, 0.75, total_height,total_height, 0,0, 1.875,0,0];
figure(1); % opening a figure]
plot(xpos,ypos,'ko-','Linewidth',1.5) % plotting with thicker lines
grid on; axis equal; % making selections for showing equal size ratios in both directions
axis([1.2*total_width/2*[-1,1],[-.25,1.1*total_height]]) % expanding axes to show full view
text((-125/224),0,'1','VerticalAlignment','top', 'Color', 'r');
text(-(25/28),total_height,'2','VerticalAlignment','bottom', 'Color', 'r');
text(-(75/112),total_height,'3','VerticalAlignment','bottom', 'Color', 'r');
text(-(25/56), 0.75,'4','VerticalAlignment','top', 'Color', 'r');
text(-(25/224), total_height,'5','VerticalAlignment','bottom', 'Color', 'r');
text((25/224), total_height,'6','VerticalAlignment','bottom', 'Color', 'r');
text((25/56), 0.75,'7','VerticalAlignment','top', 'Color', 'r');
text((75/112), total_height,'8','VerticalAlignment','bottom', 'Color', 'r');
text((25/28), total_height,'9','VerticalAlignment','bottom', 'Color', 'r');
text((125/224),0,'10','VerticalAlignment','top', 'Color', 'r');
text((75/224),0,'11','VerticalAlignment','top', 'Color', 'r');
text(0,1.875,'12','VerticalAlignment','bottom', 'Color', 'r');
text(-(75/224),0,'13','VerticalAlignment','top', 'Color', 'r');

Best Answer

Use arc length interpolation and smooth data
[x,y] = pol2cart(-pi:1:pi,5);
tt = [0 cumsum(hypot(diff(x),diff(y)))]; % create arc length
t1 = linspace(0,tt(end),100); % more points
x1 = interp1(tt,x,t1); % interpolate x
y1 = interp1(tt,y,t1); % interpolate y
x2 = smooth(x1,5); % smooth x
y2 = smooth(y1,5); % smooth y
plot(x,y,':')
line(x2,y2)
See here: LINK