フィルターのクリア

select the correct row in a table with a different index in the for loop

1 回表示 (過去 30 日間)
g
g 2021 年 11 月 25 日
回答済み: Peter Perkins 2021 年 11 月 26 日
Good mornin,
within a for loop (with an index i ranging from 1 to 1440 with an interval of 5( for i:1:5:1440)) I need to select the correct row of a table (containing 288 rows). The problem is that the index of the for loop does not correspond to the correct row of the table, because for i=5 I have to select row 2 of the table, then for i=10 I have to select row 3 of the table and so on. What can I do?
Thanks

採用された回答

HWIK
HWIK 2021 年 11 月 25 日
編集済み: HWIK 2021 年 11 月 25 日
Is this what you are looking for?
for i=1:5:1440
j = i==1:5:1440;
end
Where j would be your new index in sequential order.

その他の回答 (2 件)

dpb
dpb 2021 年 11 月 25 日
j=1;
for i=1:5:1440
j=j+1;
...
end

Peter Perkins
Peter Perkins 2021 年 11 月 26 日
Giulia, you got an asnwer to your specific question, but it's quite possible that you asked too specific a question, and didn't give enough context. Maybe you don't need to loop at all, consider something like
A2 = A(1:5:1440)
Also, 1440 suggests that you should be using a timetable, so maybe something like
a = tt.A(1:5:1440)
And if you need something every 5 minutes, then perhaps look into using retime.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by