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?
2 views (last 30 days)
Show older comments
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)]);
0 Comments
Answers (1)
Sam Chak
on 23 Sep 2024
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')
0 Comments
See Also
Categories
Find more on Fuzzy Logic Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!