-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuzzyctrl.m
More file actions
53 lines (49 loc) · 1.13 KB
/
fuzzyctrl.m
File metadata and controls
53 lines (49 loc) · 1.13 KB
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
51
52
53
function [ vL, vR, du ] = fuzzyctrl( err )
persistent base u fismatrix err1
if nargin < 1 || nargout == 0
fisFileName = 'agv';
fismatrix = readfis(fisFileName);
u = 0;
base = 12;
err1 = 0;
showRuleViewer(fismatrix);
return
end
showRuleViewer([err;err - err1]);
du = evalfis([err;err - err1],fismatrix);
u = u + du;
if u>base
u = base;
elseif u<-base
u=-base;
end
vL = base - u ;
vR = base + u ;
err1 = err;
end
function showRuleViewer(fismatrix)
persistent fig
if isnumeric(fismatrix)
if ~isempty(fig)
set(fig, 'HandleVisibi', 'on');
ruleview('#simulink', fismatrix, fig);
set(fig, 'HandleVisibi', 'callback');
return;
end
end
% ¼ì²âÊÇ·ñ»æÖÆÍ¼ÐÎ
mapfig = findall(0,'Type','figure','Name','map');
if isempty(mapfig)
fig = mapfig;
return
end
fig = findall(0,'Type','figure','Name',sprintf('Rule Viewer: %s',fismatrix.name));
if isempty(fig)
ruleview(fismatrix);
fig = findall(0,'Type','figure','Name',sprintf('Rule Viewer: %s',fismatrix.name));
position=get(fig, 'Position');
set(fig, 'Position', position+[.2 -.2 0 0]);
else
figure(fig);
end
end