I have a problem in which I have to define a fuzzy membership function with variable x(1) x(2) like below. For these variables I have to generate random number between 1 and 5. x(1)<x(2). What will be code for that?

1 回表示 (過去 30 日間)
p d
p d 2017 年 6 月 20 日
回答済み: Sam Chak 2024 年 9 月 23 日
I have a problem in which I have to define a fuzzy membership function with variable x(1) x(2) like below. For these variables I have to generate random number between 1 and 5. x(1)<x(2). What will be code for that? a=addmf(a,'input',1,'P','trimf',[0 x(1) x(2)]);

回答 (1 件)

Sam Chak
Sam Chak 2024 年 9 月 23 日
Set a constraint on so that .
fis = sugfis;
%% Random integer generator
n1 = 3;
n2 = 5 - n1;
x1 = randi(n1, 1);
x2 = randi(n2, 1) + x1; % ensures x1 < x2
%% Fuzzy Input 1
fis = addInput(fis, [-1 +5], 'Name', 'x');
fis = addMF(fis, 'x', 'trimf', [0 x1 x2], 'Name', 'P');
%% Plot membership functions for input 1
plotmf(fis, 'input', 1), grid on, title('MFs for x')

カテゴリ

Help Center および File ExchangeFuzzy Logic Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by