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

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...

 채택된 답변

Voss
Voss 2021년 12월 18일
편집: Voss 2021년 12월 18일
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

Ohhh... Im just aware of that weird... So how to filter data in range of -2< the_noising_gauss_ori <2 as my Detecting Noise Index (rownumber) so that the rownumber from that range data can be used as replacing index to my the_original_sinyal2 data, Sir?
Voss
Voss 2021년 12월 18일
편집: Voss 2021년 12월 18일
I guess I would try 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(mov_remove_gauss_ori_pos & mov_remove_gauss_ori_neg)
the_original_sinyal2(mov_remove_gauss_ori_pos & mov_remove_gauss_ori_neg) = nan;
the_original_sinyal1(mov_remove_gauss_ori_pos & mov_remove_gauss_ori_neg) = nan;
end
I can't say for sure since I do not have any of the data or know anything about the sizes of the variables.
Alright, i ll try it..
@Benjamin Its still wont allow me to get NaN data of the_original_sinyal2 in -2< the_noising_gauss_ori <2 numrow, Sir.... I already attached my Data, Take the column 3 from my data.
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 2021년 12월 21일
편집: Tyann Hardyn 2021년 12월 21일
May Allah Bless You, It Works, Sir, Thank you so much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2021년 12월 18일

편집:

2021년 12월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by