looping through multiple numbers

2 views (last 30 days)
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,:);
avsize = [1:1:45]
for i = 1:length(avsize)
a_t(i) = A(A(:,2) > avsize,:);
The logical indices in position 1 contain a true value outside of the array bounds.

Accepted Answer

Walter Roberson
Walter Roberson on 26 May 2022
a_t(i) = A(A(:,2) > avsize(i),:);
Walter Roberson
Walter Roberson on 26 May 2022
all_w_t{i} = w_t(w_t >15,:);

Sign in to comment.

More Answers (0)


Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!