error with the trapmf function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ameri
el 20 de Nov. de 2022
Comentada: Ameri
el 21 de Nov. de 2022
Dear Sir/ Madam
I would like to ask for a sloution fot this problem please.
What should I do? Thank you
0 comentarios
Respuesta aceptada
John D'Errico
el 20 de Nov. de 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 comentarios
John D'Errico
el 21 de Nov. de 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?
Más respuestas (0)
Ver también
Categorías
Más información sobre Fuzzy Logic Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!