How to update global logical array from local logical array.
Show older comments
Hi, dear Community,
I want to create something like this:
i have global logical_array = [1,1,1,1,1,1,1,1]
I want to change the logical array to zero based on the sequence (the smallest value first)
from A: 1 (index 3) to be remove as first, then 2(index 5) as second, then 3(index 4) as third, then 4(index 1) as forth and 4 (index 5) as fifth,
from log_array = [1,1,0,1,1,1,1,1,], then [1,1,0,1,0,1,1,1], then [1,1,0,0,0,1,1,1], then [0,1,0,0,0,1,1,1], then [0,0,0,0,0,1,1,1],
At the same time i want to write the logical array into Zero, when that global position has been removed.
The end answer of logical array should be [0 0 0 0 0 1 1 1].
The loop should run until no values is < f_min.
How can i do this step by step?
Thanks a lot.
log_array = [true, true, true, true, true, true, true, true];
A = [4 4 1 3 2 7 8 9]';
DoF = 4;
f_min = 5;
r = length(A)-DoF;
while r ~= 0
if any (A< f_min)
[A_diff, f_id] = min(A-f_min);
log_array (f_id) = 0 %%Problem here
A (f_id) = []
r = length(A)-DoF; %r will be reduced by one in every loop
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!