Skip to content

Commit a19c5dc

Browse files
committed
Update commit R2025b
1 parent 675109e commit a19c5dc

415 files changed

Lines changed: 3603 additions & 88 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
function [xy_data] = Extr_Data_Block_NotchCircle(box_x, box_y, notch_rad, notch_th, box_r, varargin)
2+
%Extr_Data_Block_NotchCircle Produce extrusion data for a rectangle with rounded corners.
3+
% [xy_data] = Extr_Data_Block_NotchCircle(height, width, radius, varargin)
4+
% This function returns x-y data for a rectangle with rounded corners.
5+
% You can specify:
6+
% Width box_x
7+
% Height box_y
8+
% Notch radius notch_rad
9+
% Notch theta notch_th
10+
% Radius, outer fillet box_r
11+
%
12+
% To see a plot showing parameter values, enter the name
13+
% of the function with no arguments
14+
% >> Extr_Data_Block_NotchCircle
15+
%
16+
% To see a plot created with your parameter values,
17+
% add 'plot' as the final argument
18+
% >> Extr_Data_Block_NotchCircle(2,1,0.7,45,0.2,'plot')
19+
20+
% Copyright 2012-2026 The MathWorks, Inc.
21+
22+
% Default data to show diagram
23+
if (nargin == 0)
24+
box_x = 0.02;
25+
box_y = 0.01;
26+
notch_rad = 0.007;
27+
notch_th = 45;
28+
box_r = 0.002;
29+
end
30+
31+
if (nargin == 6)
32+
showplot = varargin{end};
33+
else
34+
showplot = 'n';
35+
end
36+
37+
% Check if plot should be produced
38+
if (isempty(varargin))
39+
showplot = 'n';
40+
end
41+
42+
%box_oy = b_D/2-(b_D+b_d)/4-notch_rad*cosd(notch_th);
43+
%box_ox = b_b;
44+
45+
% Create outer profile
46+
if (box_r>0)
47+
xyset1 = [box_x/2 0;box_x/2 box_y-box_r ];
48+
xyset3 = [box_x/2-box_r box_y;-box_x/2+box_r box_y];
49+
xyset5 = [-box_x/2 box_y-box_r;-box_x/2 0];
50+
% xyset7 = [box_ox/2 -box_oy/2+rad_o;box_ox/2 box_oy/2-rad_o];
51+
52+
xyset2 = [Extr_Data_Ring(box_r,0,1,89)];
53+
xyset2(:,1) = xyset2(:,1)+(box_x/2-box_r);
54+
xyset2(:,2) = xyset2(:,2)+(box_y-box_r);
55+
xyset4 = [Extr_Data_Ring(box_r,0,91,179)];
56+
xyset4(:,1) = xyset4(:,1)+(-box_x/2+box_r);
57+
xyset4(:,2) = xyset4(:,2)+(box_y-box_r);
58+
xy_data = [xyset1; xyset2; xyset3; xyset4; xyset5];
59+
else
60+
xyset1 = [box_x/2 box_y/2];
61+
xyset3 = [-box_x/2 box_y/2];
62+
xyset5 = [-box_x/2 -box_y/2];
63+
xy_data = [xyset1; xyset3; xyset5];
64+
end
65+
66+
xyset6 = flipud(Extr_Data_Ring(notch_rad,-1,-notch_th+90,notch_th+90));
67+
xyset6 = xyset6 + [0 -notch_rad*cosd(notch_th)];
68+
xy_data=[xy_data;xyset6];
69+
70+
%xy_data = xy_data + [0 (b_D+b_d)/4+sph_r*cosd(race_th)];
71+
72+
73+
% Plot diagram to show parameters and extrusion
74+
if (nargin == 0 || strcmpi(showplot,'plot'))
75+
76+
% Figure name
77+
figString = ['h1_' mfilename];
78+
% Only create a figure if no figure exists
79+
figExist = 0;
80+
fig_hExist = evalin('base',['exist(''' figString ''')']);
81+
if (fig_hExist)
82+
figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']);
83+
end
84+
if ~figExist
85+
fig_h = figure('Name',figString);
86+
assignin('base',figString,fig_h);
87+
else
88+
fig_h = evalin('base',figString);
89+
end
90+
figure(fig_h)
91+
clf(fig_h)
92+
93+
% Plot extrusion
94+
patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none');
95+
hold on
96+
plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2);
97+
axis('equal');
98+
axis([-1.1 1.1 -0.6 1.6]*max(box_y/2,box_x/2));
99+
100+
% Show parameters
101+
hold on
102+
103+
plot([-1 -1]*0.4*box_x/2,[0 box_y],'r-d','MarkerFaceColor','r');
104+
text(-0.45*box_x/2,box_y*0.5,'{\color{red}box\_y}','HorizontalAlignment','right');
105+
106+
plot([-box_x/2 box_x/2],[1 1]*box_y*0.2,'b-d','MarkerFaceColor','b');
107+
text(box_x/2*0.25,box_y*0.25,'{\color{blue}box\_ox}');
108+
109+
radius_label_angle = 45*(pi/180);
110+
plot([box_x/2-box_r box_x/2-box_r*(1-cos(radius_label_angle))],[box_y-box_r box_y-box_r*(1-sin(radius_label_angle))],'k-d','MarkerFaceColor','k');
111+
text(box_x/2-2*box_r*(cos(radius_label_angle)),box_y-2*box_r*(sin(radius_label_angle)),'{\color{black}rad\_o}','HorizontalAlignment','center');
112+
113+
plot([0 0],[0 notch_rad*1.2]-notch_rad*cosd(notch_th),'k:');
114+
plot([0 sind(notch_th)]*notch_rad,([0 cosd(notch_th)]*notch_rad)-notch_rad*cosd(notch_th),'k-d','MarkerFaceColor','k');
115+
text(notch_rad*sind(notch_th)*1.1,0,'{\color{black}notch\_rad}','HorizontalAlignment','left');
116+
117+
arc1_r = 0.75*notch_rad;
118+
arc1 = linspace(0,notch_th,50)'*pi/180;
119+
plot(sin(arc1)*arc1_r,cos(arc1)*arc1_r-notch_rad*cosd(notch_th),'g--');
120+
plot(sin(arc1(1))*arc1_r,cos(arc1(1))*arc1_r-notch_rad*cosd(notch_th),'gd','MarkerFaceColor','g');
121+
plot(sin(arc1(end))*arc1_r,cos(arc1(end))*arc1_r-notch_rad*cosd(notch_th),'gd','MarkerFaceColor','g');
122+
text(-0.02*box_x,(0.75-cosd(notch_th))*notch_rad,'{\color{green}notch\_th}','HorizontalAlignment','right');
123+
124+
title(['[xy\_data] = Extr\_Data\_Block\_NotchCircle(box\_x, box\_y, notch\_rad, notch\_th, box\_r)'],'FontSize',10);
125+
hold off
126+
box on
127+
clear xy_data
128+
end
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
function [xy_data] = Extr_Data_Box(box_ox, box_ix, varargin)
2+
%Extr_Data_Box Produce extrusion data for a hollow box.
3+
% [xy_data] = Extr_Data_Box(box_ox, box_ix, <box_oy>, <box_iy>)
4+
% This function returns x-y data for a hollow box.
5+
% You can specify:
6+
% Box outer width (x) box_ox
7+
% Box inner width (x) box_ix
8+
% (optional) Box outer height (y) box_oy
9+
% (optional) Box inner height (y) box_iy
10+
%
11+
% To see a plot showing parameter values, enter the name
12+
% of the function with no arguments
13+
% >> Extr_Data_Box
14+
%
15+
% To see a plot created with your parameter values,
16+
% add 'plot' as the final argument
17+
% >> Extr_Data_Box(10,5,'plot')
18+
19+
% Copyright 2013-2026 The MathWorks, Inc.
20+
21+
% Default data to show diagram
22+
if (nargin == 0)
23+
box_ox = 15;
24+
box_ix = 12;
25+
box_oy = 10;
26+
box_iy = 5;
27+
elseif (nargin <= 3)
28+
box_oy = box_ox;
29+
box_iy = box_ix;
30+
elseif (nargin > 3)
31+
box_oy = varargin{1};
32+
box_iy = varargin{2};
33+
end
34+
35+
if (nargin==0)
36+
showplot = 'plot';
37+
elseif (nargin==3 || nargin==5)
38+
showplot = varargin(end);
39+
else
40+
showplot = 'n';
41+
end
42+
43+
% Generate extrusion data
44+
x_signs = [1 -1 -1 1]';
45+
y_signs = [1 1 -1 -1]';
46+
xy_data = [box_ox/2*x_signs box_oy/2*y_signs];
47+
if(box_ix>0 && box_iy>0)
48+
xy_data = [xy_data;box_ox/2 box_oy/2;box_ix/2*y_signs box_iy/2*x_signs;box_ix/2 box_iy/2];
49+
end
50+
51+
% Plot diagram to show parameters and extrusion
52+
if (nargin == 0 || strcmpi(showplot,'plot'))
53+
54+
% Figure name
55+
figString = ['h1_' mfilename];
56+
% Only create a figure if no figure exists
57+
figExist = 0;
58+
fig_hExist = evalin('base',['exist(''' figString ''')']);
59+
if (fig_hExist)
60+
figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']);
61+
end
62+
if ~figExist
63+
fig_h = figure('Name',figString);
64+
assignin('base',figString,fig_h);
65+
else
66+
fig_h = evalin('base',figString);
67+
end
68+
figure(fig_h)
69+
clf(fig_h)
70+
71+
% Get max axis dimension
72+
maxd = max(box_ox,box_oy);
73+
74+
% Plot extrusion
75+
patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none');
76+
hold on
77+
plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2);
78+
axis('equal');
79+
axis([-1.1 1.1 -1.1 1.1]*maxd/2);
80+
81+
% Show parameters
82+
hold on
83+
84+
plot([-1 1]*box_ox/2,[0 0],'r-d','MarkerFaceColor','r');
85+
text(0.25*box_ox,0.025*maxd,'{\color{red}box\_ox}');
86+
87+
plot([0 0],[-1 1]*box_oy/2,'g-d','MarkerFaceColor','g');
88+
text(0,-0.4*box_oy,'{\color{green}box\_oy}');
89+
90+
if(box_ix>0 && box_iy>0)
91+
plot([-1 1]*box_ix/2,[1 1]*0.25*box_iy,'b-d','MarkerFaceColor','b');
92+
text(0.25*box_ix,0.03*maxd+0.25*box_iy,'{\color{blue}box\_ix}');
93+
94+
plot([-1 -1]*0.25*box_ix,[-1 1]*box_iy/2,'k-d','MarkerFaceColor','k');
95+
text(-0.25*box_ix+0.03*maxd,0.4*box_iy,'{\color{black}box\_iy}');
96+
end
97+
title('[xy\_data] = Extr\_Data\_Box(box\_ox, box\_ix, <box\_oy, box\_iy>);');
98+
hold off
99+
box on
100+
clear xy_data
101+
end
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
function [xy_data] = Extr_Data_Cam_Circles(rad1, rad2, d, radh1, radh2, varargin)
2+
%Extr_Data_Cam_Circles Produce extrusion data for a cam formed from two circles.
3+
% [xy_data] = Extr_Data_Cam_Circles(rad1, rad2, d, radh1, radh2)
4+
% This function returns x-y data for a cam formed from two circles
5+
% that are connected by lines tangent to the circles.
6+
%
7+
% You can specify:
8+
% Radius, circle 1 rad1
9+
% Radius, circle 2 rad2
10+
% Distance between circle centers d
11+
% Radius of hole at center of circle 1 radh1
12+
% Radius of hole at center of circle 2 radh2
13+
%
14+
% To see a plot showing parameter values, enter the name
15+
% of the function with no arguments
16+
% >> Extr_Data_Cam_Circles
17+
%
18+
% To see a plot created with your parameter values,
19+
% add 'plot' as the final argument
20+
% >> Extr_Data_Cam_Circles(4,3,5,1,0,'plot')
21+
22+
% Copyright 2012-2026 The MathWorks, Inc.
23+
24+
% Default data to show diagram
25+
if (nargin == 0)
26+
rad1 = 4;
27+
rad2 = 3;
28+
d = 5;
29+
radh1 = 1;
30+
radh2 = 1;
31+
end
32+
33+
% Check if plot should be produced
34+
if (isempty(varargin))
35+
showplot = 'n';
36+
else
37+
showplot = varargin;
38+
end
39+
40+
% Calculate angle for external tangent
41+
theta1 = acos((rad1-rad2)/d)*180/pi;
42+
43+
% Start circle at 90 degrees to avoid self-intersecting polygons
44+
theta_cir = [90:1:360+90]'*pi/180;
45+
unit_cir = [cos(theta_cir), sin(theta_cir)];
46+
47+
% Calculate extrusion data
48+
% Arc for rad1
49+
theta_r1 = [(theta1:1:360-theta1)]'*pi/180;
50+
unit_arc = [cos(theta_r1), sin(theta_r1)];
51+
xy_data1 = [rad1 * unit_arc];
52+
if(radh1>0)
53+
% Circle for radh1
54+
xy_data1 = [xy_data1(1,:);radh1 * flipud(unit_cir);xy_data1];
55+
end
56+
57+
% Arc for rad2
58+
theta_r2 = [(-theta1:1:theta1)]'*pi/180;
59+
unit_arc = [cos(theta_r2), sin(theta_r2)];
60+
xy_data2 = [rad2 * unit_arc]+repmat([d 0],size(unit_arc,1),1);
61+
if(radh2>0)
62+
% Circle for radh2
63+
xy_data2 = [xy_data2;radh2 * flipud(unit_cir)+repmat([d 0],size(unit_cir,1),1);xy_data2(end,:)];
64+
end
65+
66+
xy_data = [xy_data1;xy_data2];
67+
68+
% Plot diagram to show parameters and extrusion
69+
if (nargin == 0 || strcmpi(showplot,'plot'))
70+
71+
% Figure name
72+
figString = ['h1_' mfilename];
73+
% Only create a figure if no figure exists
74+
figExist = 0;
75+
fig_hExist = evalin('base',['exist(''' figString ''')']);
76+
if (fig_hExist)
77+
figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']);
78+
end
79+
if ~figExist
80+
fig_h = figure('Name',figString);
81+
assignin('base',figString,fig_h);
82+
else
83+
fig_h = evalin('base',figString);
84+
end
85+
figure(fig_h)
86+
clf(fig_h)
87+
88+
% Plot extrusion data
89+
patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.90,'EdgeColor','none');
90+
hold on
91+
plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2);
92+
axis('square');
93+
axis([-rad1 d+rad2 [-1 1]*(rad1+d+rad2)/2]*1.1);
94+
95+
% Show parameters
96+
hold on
97+
plot([0 d],[0 0],'k-d','MarkerFaceColor','k','MarkerSize',10);
98+
text(d/2,0.1*max(rad1,rad2),'d');
99+
100+
plot([d d+rad2*cos(theta1*pi/180)],[0 rad2*sin(theta1*pi/180)],'r-d','MarkerFaceColor','r');
101+
text(d+rad2*cos(theta1*pi/180)/2,rad2*sin(theta1*pi/180)/2,'{\color{red}rad2}');
102+
103+
plot([0 rad1*cos(theta1*pi/180)],[0 rad1*sin(theta1*pi/180)],'g-d','MarkerFaceColor','g');
104+
text(rad1*cos(theta1*pi/180)/2,rad1*sin(theta1*pi/180)/2,'{\color{green}rad1}');
105+
106+
title(['[xy\_data] = Extr\_Data\_Cam(rad1, rad2, d1);']);
107+
hold off
108+
box on
109+
clear xy_data
110+
end

0 commit comments

Comments
 (0)