エクセルのcsvファ​イルにおいて、同列内​の12行おきにデータ​を分ける方法

12 views (last 30 days)
sora nasu
sora nasu on 10 Sep 2021
Commented: sora nasu on 13 Sep 2021
上図のエクセルのcsvファイルに、13種類の商品IDのデータが入っているのですが、それぞれの商品IDごとにデータを分けたいのですが、やり方がわからないので教えていただいきたいです。よろしくおねがいします。

Accepted Answer

Hernia Baby
Hernia Baby on 10 Sep 2021
まずはテーブルを読み込みます
日本語対応にするためにオプションを設定します
A = readtable('Sample.xlsx','PreserveVariableNames',true)
A = 17×5 table
商品ID データ計測 ______ _________ ________ ________ ________ 1 25.947 0.84936 0.33512 0.99282 2 26.054 0.10433 0.97701 0.61478 3 26.191 0.63943 0.58172 0.15767 1 26.328 0.69841 0.22126 0.55292 2 26.032 0.30457 0.32254 0.40155 3 26.558 0.24449 0.46004 0.40982 1 26.619 0.91807 0.69688 0.47275 2 26.629 0.554 0.42837 0.074617 3 26.153 0.60936 0.84978 0.14715 1 26.629 0.069917 0.88754 0.11309 2 26.639 0.39467 0.61169 0.20639 3 26.712 0.55488 0.28492 0.7073 1 26.835 0.20463 0.78117 0.75988 2 26.315 0.71485 0.22704 0.80399 3 26.598 0.67328 0.014335 0.48158 1 26.72 0.092947 0.7794 0.68988
つぎに unique で配列の一意の値を抽出します
id = unique(A.("商品ID"))
id = 3×1
1 2 3
ここで A1 に id の一番目( id = 1)に該当するtableを抽出します
A1 = A(A.("商品ID") == id(1),:)
A1 = 6×5 table
商品ID データ計測 ______ _________ ________ _______ _______ 1 25.947 0.84936 0.33512 0.99282 1 26.328 0.69841 0.22126 0.55292 1 26.619 0.91807 0.69688 0.47275 1 26.629 0.069917 0.88754 0.11309 1 26.835 0.20463 0.78117 0.75988 1 26.72 0.092947 0.7794 0.68988
  1 Comment
sora nasu
sora nasu on 13 Sep 2021
迅速な対応本当にありがとうございます。解決いたしました。

Sign in to comment.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!