how to save values from'if' loop?
Show older comments
for j = 1:sz_idx1(1,1)
new_idx = idx1(j);
alt_i = alt{new_idx};
if ( alt_i== 'T')
A_T = count+1;
end
end
Accepted Answer
More Answers (1)
What about:
A_T = cumsum(strcmp(alt{idx1}, 'T'))
instead of the loops? Or perhaps you want:
A_T = sum(strcmp(alt{idx1}, 'T'))
or
A_T = 1:sum(strcmp(alt{idx1}, 'T'))
Categories
Find more on Introduction to Installation and Licensing 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!