Hello
I got a 6x6x365 matrix. 365 refers to days in the year 6x6 are individual values.
I am trying to find a way of writing a loop that would:
  • identify changes in the 6x6 values, BUT - the values have to change by (more or equal to) 24 and the change has to occur in the same place in the matrix AND the day after yesterday (for example there is a value of 50 in a third row, third column, the next day it drops to 20 also in a third row, third column)
  • create another 6x6x365 matrix with the results (I was thinking of a binary matrix - 0 everywhere where there's no change and 1 when the change occurs)
I'm slightly out of ideas on how to approach the problem (especially the same column-same row part and creating a Boolean matrix)
I'm also open to any other ideas of how to sort the data
Any help would be very appreciated, thank you

 採用された回答

the cyclist
the cyclist 2023 年 3 月 27 日

1 投票

If M is your data,
bigChange = abs(diff(M,1,3)) >= 24;

5 件のコメント

OcDrive
OcDrive 2023 年 3 月 27 日
That seems to be a good way of doing that; do you know why does it only look for the differences in a first column of my data?
Running the code below I get that kind of table:
6 1 3
7 1 3
8 1 3
11 1 3
12 1 3
22 1 7
23 1 7
3 1 24
4 1 24
9 1 24
15 1 34
21 1 34
27 1 34
25 1 50
26 1 50
30 1 50
31 1 50
36 1 50
27 1 53
drop24 = abs(diff(SLPlimited,1,3)) >= 24;
idx=find(drop24==1);
[row,col,day]=ind2sub(size(idx),idx);
ST=[row,col,day]
the cyclist
the cyclist 2023 年 3 月 27 日
編集済み: the cyclist 2023 年 3 月 27 日
This algorithm does not only look in the first column. It searches the whole array.
Can you upload SLPlimited, in a MAT file? (You can use the paper clip icon in the INSERT section of the toolbar.)
OcDrive
OcDrive 2023 年 3 月 28 日
編集済み: OcDrive 2023 年 3 月 28 日
I'm attaching it here.
I suppose it's possible that the change only occurs in the first column of the data but it wouldn't really make sense in the real life.
the cyclist
the cyclist 2023 年 3 月 28 日
You need
[row,col,day]=ind2sub([6,6,364],idx);
instead of
[row,col,day]=ind2sub(size(idx),idx);
OcDrive
OcDrive 2023 年 3 月 28 日
That works great. Thanks so much!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

質問済み:

2023 年 3 月 27 日

コメント済み:

2023 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by