How to generate 2-D Lookup Table data for the Fuzzy PID Controller

4 次查看(过去 30 天)
Can you please help me? I have a problem when I am making 2D look up table, from .fis file. I use evalfis function, but it only works when I have 1 output in .fis file, but my .fis file has 3 outputs. And then MATLAB shows me this:
Error using evalfis (line 70)
Input data must have as many columns as input variables and as many rows as independent sets of input values.
Error in Lookup (line 21)
LookUpTableData_s = evalfis([S DS], fis_skr);
Please help if you know. Thanks in advance!
  1 个评论
Sam Chak
Sam Chak 2025-4-24
Let us create a scenario that causes the error message to appear. A typical Fuzzy PID controller has two inputs: a state (S) and the time derivative of the state (DS). Although the syntax for the older version of evalfis([S, DS], fis_skr) appears to be correct, the input values are arranged in row data form, which triggers the message reminding the user that 'Input data must have as many columns as input variables.' Resolving the issue is as simple as rearranging the input values into column data form.
fis_skr = readfis("tipper");
%% inputs as row data
S = (0:10) % state
S = 1×11
0 1 2 3 4 5 6 7 8 9 10
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
DS = (0:10) % time derivative of the state
DS = 1×11
0 1 2 3 4 5 6 7 8 9 10
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
%% evaluation
LookUpTableData_s = evalfis(fis_skr, [S DS])
Error using fuzzy.internal.utility.evalfis (line 84)
Input data must have as many columns as input variables and as many rows as independent sets of input values.

Error in evalfis (line 98)
[varargout{1:nargout}] = fuzzy.internal.utility.evalfis(varargin{:});

请先登录,再进行评论。

回答(1 个)

Sam Chak
Sam Chak 2025-4-24
For simplicity, you can create three individual 2-D lookup tables for the three fuzzy outputs generated from a single MIMO fuzzy system .fis file. In the following demo, I used the Fuzzy Tipper, which has two inputs and one output.
Generally, 2-D lookup table data are created using two for-loops, as there are two dimensions of inputs. However, since the evalfis() command can handle vectorized data, we can reduce the code to use only a single for-loop.
fis = readfis("tipper");
%% inputs (arranged in column data form)
service = (0:10)';
food = (0:10)';
%% generate 2D Lookup Data
for i = 1:numel(service)
Tip(:,i) = evalfis(fis, [repmat(service(i), numel(food), 1), food]);
end
%% plot lookup data as a surface
[Service, Food] = meshgrid(service);
figure
surf(Service, Food, Tip)
xlabel("Service"), ylabel("Food"), zlabel("Tip")
title("Visualize 2D Lookup Table Data as a Surface")
%% compare result with gensurf
gensurf(fis)
title("Surface using gensurf")

类别

Help CenterFile Exchange 中查找有关 Fuzzy Logic Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by