Weird Behavior Of Replacing Data Array In a Certain Range ...

1 view (last 30 days)
Hi, Community
I want to ask about how to delete array data with a certain range. So i have this code below :
the_noising_gauss_ori = vertcat(transpose(noising_gauss_ori)); %Other related variable was sucessfully linked
mov_remove_gauss_ori_pos = the_noising_gauss_ori >= 2; %Other related variable was sucessfully linked
mov_remove_gauss_ori_neg = the_noising_gauss_ori <= -2; %Other related variable was sucessfully linked
detecting_noise_pos = the_noising_gauss_ori < 2; %Other related variable was sucessfully linked
detecting_noise_neg = the_noising_gauss_ori > -2; %Other related variable was sucessfully linked
gaussian_filter = imgaussian(graph_gauss_ori, zigm, [l_wak 1]); %Other related variable was sucessfully linked
if ~isempty(mov_remove_gauss_ori_neg) || ~isempty(mov_remove_gauss_ori_neg)
the_original_sinyal2(detecting_noise_pos) = nan;
the_original_sinyal2(detecting_noise_neg) = nan;
the_original_sinyal1(mov_remove_gauss_ori_pos) = gaussian_filter(mov_remove_gauss_ori_pos);
the_original_sinyal1(mov_remove_gauss_ori_neg) = gaussian_filter(mov_remove_gauss_ori_neg);
end
When i run that code, the variable array of the_original_sinyal1(mov_remove_gauss_ori_pos) and the_original_sinyal1(mov_remove_gauss_ori_neg) is good, it can be replaced with its relative data from gaussian_filter(mov_remove_gauss_ori_pos) and gaussian_filter(mov_remove_gauss_ori_neg).... How ever, the variable array of the_original_sinyal2(detecting_noise_pos) and the_original_sinyal2(detecting_noise_neg) cannot filter the data with that range (the_noising_gauss_ori < 2 or the_noising_gauss_ori > -2) and just shown as NaN data for all of the_original_sinyal2 variable....
How to fix my problem, anyone. I just want to replace the_original_sinyal2 variable with a same rows as the_noising_gauss_ori < 2 or the_noising_gauss_ori > -2 as NaN.... Thank you very much...

Accepted Answer

Voss
Voss on 18 Dec 2021
Edited: Voss on 18 Dec 2021
Any (real) number is either less than 2 or greater than -2 (or both). Therefore detecting_noise_pos | detecting_noise_neg is all true. Hence, the_original_sinyal2 is all NaN after doing this:
the_original_sinyal2(detecting_noise_pos) = nan;
the_original_sinyal2(detecting_noise_neg) = nan;
  6 Comments
Voss
Voss on 18 Dec 2021
Sorry I should've said this:
the_noising_gauss_ori = vertcat(transpose(noising_gauss_ori)); %Other related variable was sucessfully linked
mov_remove_gauss_ori_pos = the_noising_gauss_ori >= 2; %Other related variable was sucessfully linked
mov_remove_gauss_ori_neg = the_noising_gauss_ori <= -2; %Other related variable was sucessfully linked
detecting_noise_pos = the_noising_gauss_ori < 2; %Other related variable was sucessfully linked
detecting_noise_neg = the_noising_gauss_ori > -2; %Other related variable was sucessfully linked
gaussian_filter = imgaussian(graph_gauss_ori, zigm, [l_wak 1]); %Other related variable was sucessfully linked
if any(detecting_noise_pos & detecting_noise_neg)
the_original_sinyal2(detecting_noise_pos & detecting_noise_neg) = nan;
end
if any(mov_remove_gauss_ori_neg | mov_remove_gauss_ori_pos)
the_original_sinyal1(mov_remove_gauss_ori_neg | mov_remove_gauss_ori_pos) = gaussian_filter(mov_remove_gauss_ori_neg | mov_remove_gauss_ori_pos);
end
This will set the_original_sinyal2 to NaN wherever -2 < the_noising_gauss_ori < 2, and set the_original_sinyal1 equal to gaussian_filter wherever (the_noising_gauss_ori >= 2 OR the_noising_gauss_ori <= -2). Is this what is intended?
By the way, the third column of the data is all around 40000. If the third column represents the_noising_gauss_ori, then this code will set the_original_sinyal1 equal to gaussian_filter everywhere and will not change the_original_sinyal2. If that's what you observe and it looks wrong, then perhaps the data is not as you expect.
Tyann Hardyn
Tyann Hardyn on 21 Dec 2021
Edited: Tyann Hardyn on 21 Dec 2021
May Allah Bless You, It Works, Sir, Thank you so much.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!