error with the trapmf function

5 ビュー (過去 30 日間)
Ameri
Ameri 2022 年 11 月 20 日
コメント済み: Ameri 2022 年 11 月 21 日
Dear Sir/ Madam
I would like to ask for a sloution fot this problem please.
What should I do? Thank you

採用された回答

John D'Errico
John D'Errico 2022 年 11 月 20 日
You wrote this:
x1 = 0:1:25;
y1 = trapmf(x, [0 5 15 25]) ;
Unrecognized function or variable 'x'.
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 件のコメント
John D'Errico
John D'Errico 2022 年 11 月 21 日
Why would it not be tilted? First, what is trapmf?
help trapmf
TRAPMF Trapezoidal membership function. TRAPMF(X, PARAMS) returns a matrix which is the trapezoidal membership function evaluated at X. PARAMS = [A B C D] is a 4-element vector that determines the break points of this membership function. We require that A <= B and C <= D. If B >= C, this membership function becomes a triangular membership function that could have a height less than unity. (See the example below.) For example: x = (0:0.1:10)'; y1 = trapmf(x, [2 3 7 9]); y2 = trapmf(x, [3 4 6 8]); y3 = trapmf(x, [4 5 5 7]); y4 = trapmf(x, [5 6 4 6]); plot(x, [y1 y2 y3 y4]); set(gcf, 'name', 'trapmf', 'numbertitle', 'off'); See also DSIGMF, EVALMF, GAUSS2MF, GAUSSMF, GBELLMF, PIMF, PSIGMF, SIGMF, SMF, TRIMF, ZMF, LINSMF, LINZMF. Documentation for trapmf doc 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?
Ameri
Ameri 2022 年 11 月 21 日
Thank you so much for your response. I have changed the distance from 15 to 25. To be 20 25 and now looks fine. Many thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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