Removing leading values in a matrix
2 ビュー (過去 30 日間)
古いコメントを表示
I am using the findchangept function ('std') on the below time series. The first 23 values are 0, which gets marked as the changepoint by the function (left plot). If I detect the first non-zero entry (find(x, 1)) and then analyse the data from that point onward that function works much better (right plot). My problem is in replicating this across a large matrix of data.
The matrix is 200x10000, but the first non-zero entry varies by row. I don't know how to adjust the matrix so that each row is of a different length. I'm actually using the data in a cell framework so:
%first non_zero point in each cell
first_non_zero = cellfun(@(x)(find(x, 1)), example_cell);
This yields a 200 x 1 matrix.
example_cell_adjust (i) = example_cell (i, (first_non_zero(i): end));
This doesn't work but shows what I want, a set of vectors of unequal length that I can then run the findchangept function on.
Or maybe there is a better way of using the findchangept function so that it doesn't trip on the first zero to non-zero point.
Thanks.
0 件のコメント
採用された回答
dpb
2017 年 9 月 19 日
編集済み: dpb
2017 年 9 月 19 日
Probably easiest is to just process each column in a loop...
for i=1:size(x,2) % over each column in x
iz=find(x(:,i),1); % first nonzero x location
res(i)=findchangept(x(iz:end,i)); % call the function wanted over those data
...
I don't know the findchangept function and didn't look it up to see what it returns; obviously preallocate for its output if saving for each column or use the result in the loop and go on to the next.
And, of course, you wouldn't necessarily have to have the temporaries as shown; put them here to illustrate the process more clearly.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Measurements and Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!