How to simplify this for-loop into a one line of code?
Show older comments
Attached is a file storing a cell array A, a logical array for the columns: tf, and a logical array for A: map2.
My goal is to replace the below for-loops with a one line of code:
[m n] = size(A);
for j=1:n
for i=1:m
if ~tf(j) & map2(i,j)
A{i, j} = str2double(A{i,j});
end
end
end
Why doen't the below work?
A(~tf & map2) = str2double(A(~tf & map2));
Accepted Answer
More Answers (0)
Categories
Find more on Profile and Improve Performance 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!