error with the trapmf function
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear Sir/ Madam
I would like to ask for a sloution fot this problem please.
What should I do? Thank you
0 Commenti
Risposta accettata
John D'Errico
il 20 Nov 2022
You wrote this:
x1 = 0:1:25;
y1 = trapmf(x, [0 5 15 25]) ;
So you created the variable x1. Then you called the function trapmf. What is x? Should MATLAB somehow know what it should do here? What is x? Should it read your mind, that somehow, it should know that MAYBE, you wanted to pass in x1, instead of the undefined variable x?
Software does what you tell it to do. It does not read your mind.
3 Commenti
John D'Errico
il 21 Nov 2022
Why would it not be tilted? First, what is trapmf?
help trapmf
Ok a trapezoid.
x1 = 0:1:25;
y1 = trapmf(x1, [0 5 15 25]);
plot(x1,y1)
So, a trapezoid, where the top edge is not centered. Where does that top live? It is completely controlled by the second and third break points, and where they lie, compared to the first and 4th breakpoint.
Note that the distance from 0 to 5, is NOT the same as the distance from 15 to 25.
Would you expect the result to be symmetrical? Again, computers follow your orders. They do what you tell them to do.
If you insist on symmetry, then you need to choose a set of breakpoints that would be symmetrical. Ergo, you might decide to adjust one of the numbers 5, 15 or 25 in that call. Where you want to put them is your choice. For example, what would happen if you used [0 5 20 25] as the second argument to trapmf?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Fuzzy Logic Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!