% FuzzyEx1plot.m % % Example of fuzzy logic used to control a screw-down motor that controls % how far apart rolls in a steel mill will be. The motor lacks feedback % control and coasts into place. The objective of the fuzzy logic % system is to output the time that the motor should be turned off % so that it will end up at the correct final position. Friction on % the mill varies with position. (Data is stored in FuzzyStopDist.m function.) % % The plotting of the estimated stop distance surface is accomplished by % by processing (x1, x2) points through the entire fuzzy logic system. % Create mesh for plot x1_limits = [0, 2.4]; % [min, max] for x1 (size of move). x2_limits = [0, 3.0]; % [min, max] for x2 (final position). num_pts_x1_and_x2 = 101; % number of pts in both x1 and x2 directions. % Create the x1,x2 pts x1_spacing = (x1_limits(2)-x1_limits(1))/(num_pts_x1_and_x2 - 1); x2_spacing = (x2_limits(2)-x2_limits(1))/(num_pts_x1_and_x2 - 1); x1 = x1_limits(1) : x1_spacing : x1_limits(2); x2 = x2_limits(1) : x2_spacing : x2_limits(2); [xx1,xx2] = meshgrid(x1,x2); % Evaluate the fuzzy logic surface at points on the grid. for size_of_move_index = 1:size(xx1,1) for final_pos_index = 1:size(xx2,2) size_of_move = xx1(size_of_move_index, final_pos_index); final_pos = xx2(size_of_move_index, final_pos_index); y(size_of_move_index, final_pos_index) = ... FuzzyStopDist(xx1(size_of_move_index, final_pos_index), ... xx2(size_of_move_index, final_pos_index)); end end % Plot the surface. figure(1) surf(xx1,xx2,y) set(gcf,'color','white') xlabel('size of move (inches)') ylabel('final position (inches)') zlabel('stop distance (inches)') title('Fuzzy logic system for predicting stop distance')