![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/757514/image.png)
Tableからデータを抽出する方法
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Excelから読み込むデータです。
x値とそれに対応するy値があります。x値は増加しており、xがだいたい25増えるごとにx値はしばらく一定になり、その後x値の増加が再開します。
x値が増加再開した直後からxが10増加するまでのx値とy値のグラフを自動で作成したいです。(もしくはそのデータを抜き出したいです)
説明がややこしいですがお願いします。
0 Kommentare
Antworten (1)
Akira Agata
am 4 Okt. 2021
下記のような方法はいかがでしょうか?
% データ読み込み
T = readtable('Book2.xlsx');
% xのdiffを取る (xが一定の区間は0となる)
d = [0; diff(T.x)];
% xが増加している部分 (diff > 0.1と仮定) を抽出
T.isData = d > 0.1;
% 増加開始直後の点を特定
T.isRisingEdge = [false; diff(T.isData) == 1];
% 増加開始から次の増加開始までをグループとして番号を割り当て
T.group = cumsum(T.isRisingEdge);
% 各グループについて、xが10増加するまでの x-y をプロット
figure
tiledlayout('flow')
for kk = 1:max(T.group)
idx1 = T.group == kk;
ptStart = find(idx1,1);
idx2 = T.x <= T.x(ptStart)+10;
idx = idx1 & idx2;
nexttile
plot(T.x(idx),T.y(idx))
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/757514/image.png)
0 Kommentare
Siehe auch
Kategorien
Mehr zu スプレッドシート finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!