フィルターのクリア

How to split the numerical data using discretize Function

4 ビュー (過去 30 日間)
Deborah Johnson
Deborah Johnson 2022 年 7 月 18 日
編集済み: Deborah Johnson 2022 年 7 月 20 日
My first step was to plot the Weekday of Month data as numerical values 1 - 7 which I have attached and the task was successful.
With the second step, I am attempting to "discretize" >> Weekday of Month and split the numerical data into seven groups that corrlates with each weekday value of 1 as Sunday, 2 as Monday, etc. and the new column data states Sunday for 1, etc in the table.
flights.WEEKDAY_LABEL = discretize(flights.WEEKDAY_OF_MONTH,[1, 2, 3, 4, 5, 6, 7], "categorical",["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"])
Error states: "Fourth agrument, category names, must be a cell array with length equal to the number of bins, 6." What is incorrect?

採用された回答

dpb
dpb 2022 年 7 月 19 日
編集済み: dpb 2022 年 7 月 19 日
discretize uses bin edges, not bin centers so your seven values define six bins, not seven, annoying as that is as compared to the venerable histc
Try
flights.WEEKDAY_LABEL=discretize(flights.WEEKDAY_OF_MONTH,(1:8),"categorical",["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]);
and joy will ensue...
  1 件のコメント
Deborah Johnson
Deborah Johnson 2022 年 7 月 20 日
編集済み: Deborah Johnson 2022 年 7 月 20 日
Happy Face with a big smile on my heart. Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by