-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinductor.m
50 lines (46 loc) · 1.2 KB
/
inductor.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function inductor(varargin)
%INDUCTOR Draw an inductor
% Author(s): A. DiVergilio
% Copyright 1986-2002 The MathWorks, Inc.
% $Revision: 1.6 $ $Date: 2002/04/10 06:41:54 $
%---Default properties
p = struct(...
'Parent',[],...
'Position',[2 2],...
'Size',1,...
'Angle',0,...
'LineWidth',2,...
'LineStyle','-',...
'Color','k',...
'Tag','',...
'Clipping','off');
plist = fieldnames(p);
%---Merge user-specified properties
for i=1:2:nargin-1
Property = pnmatch(varargin{i},plist);
Value = varargin{i+1};
p.(Property) = Value;
end
if isempty(p.Parent), p.Parent = gca; end
%---Draw a line
N = 100;
A = 2*0.042;
B = 2*0.24;
tend = 7*pi;
t = 0:tend/N:tend;
tmid = t((N+2)/2);
xmid = A*(1+real(exp(j*(tmid-pi)))) + B*tmid/tend;
x = 0.5 - xmid + A*(1+real(exp(j*(t-pi)))) + B*t/tend;
x = p.Size*[0 x 1];
y = p.Size*[0 .2*imag(exp(j*t)) 0];
r = sqrt(x(2:end).^2+y(2:end).^2);
a0 = atan(y(2:end)./x(2:end));
line(...
'Parent',p.Parent,...
'XData',p.Position(1)+[0 r.*cos(a0+p.Angle*pi/180)],...
'YData',p.Position(2)+[0 r.*sin(a0+p.Angle*pi/180)],...
'LineWidth',p.LineWidth,...
'LineStyle',p.LineStyle,...
'Color',p.Color,...
'Tag',p.Tag,...
'Clipping',p.Clipping);