MATLAB. I have a (2559 x 16 x 3) array named ydisplacements. I use the 'ischange' command with a specified threshold, in a loop to find points of rapid change in the data in each column, for all three planes. This I record in a logical array TF(2559 x 16 x 3) in which '1' denotes points of sharp change. I want to have TF such that in each of its columns only the most extreme change from 'ydisplacements' is recorded in it as logical 1. In other words, everything else is a logical 0, I want only one logical 1 for each column of TF. This I can do easily by increasing the threshold till my desired outcome. But my question is how I can automate this so that for each column of ydisplacements(:,i,j), the threshold keeps increasing by a predetermined value until the desired outcome of only one logical 1 is achieved in TF, before moving to the next index. I have tried this code below. Any help is appreciated. Thank you..
increment = 100;
for i = 1:size(ydisplacements,2);
for j = 1:size(ydisplacements,3);
threshold = 100;
TF(:,i,j) = ischange(ydisplacements(:,i,j),'Linear','Threshold',threshold);
if sum(TF(:,i,j) == 1)>1;
threshold = threshold + increment;
TF(:,i,j) = ischange(ydisplacements(:,i,j),'Linear','Threshold',threshold);
else
threshold = threshold;
TF(:,i,j) = ischange(ydisplacements(:,i,j),'Linear','Threshold',threshold);
end
end
end
Aucun commentaire:
Enregistrer un commentaire