looping through multiple numbers

조회 수: 4 (최근 30일)
C.G.
C.G. 2022년 5월 26일
댓글: Walter Roberson 2022년 5월 26일
I have written a script, which tells me which rows of A are above the threshold, and then the difference between the numbers in column 1 of the variable 'abovethresh'.
This works fine, however I now want to write a loop which gives me this output, for avsize = 1:1:45. So I want it to apply the new threshold and do the same thing. I've tried to get a small section of this working to build on but I am getting the error below.
%single value
avsize = 10; %define avalanche threshold
abovethresh = A(A(:, 2) > 10,:);
wait_time = diff(abovethresh(:,1));
wait_time = wait_time(wait_time >15,:);
%loop
avsize = [1:1:45]
for i = 1:length(avsize)
a_t(i) = A(A(:,2) > avsize,:);
end
The logical indices in position 1 contain a true value outside of the array bounds.

채택된 답변

Walter Roberson
Walter Roberson 2022년 5월 26일
a_t(i) = A(A(:,2) > avsize(i),:);
  댓글 수: 6
C.G.
C.G. 2022년 5월 26일
편집: C.G. 2022년 5월 26일
so are you saying I need to change the name of w_t(i) so it is not the same as the line above?
If i do that I get exactly the same error message.
Walter Roberson
Walter Roberson 2022년 5월 26일
all_w_t{i} = w_t(w_t >15,:);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by