error when using 'find' function

Hi
i actually want to find the first the first and last non zero row to avoid the edge effects and enforce them to zero for my analysis. But when i try running the code, i get this error - 'Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 0-by-1'. Here is the part of code that gives the error.
idxo1 = zeros(size(U_col,2),size(U_col,3));
idxo2 = zeros(size(U_col,2),size(U_col,3));
for j =1:size(U_col,3)-1
for k = 1:size(U_col,2)-1
idxo1(k,j) = find(EffectiveDivergence(:,k,j), 1, 'first');
idxo2(k,j) = find(EffectiveDivergence(:,k,j), 1, 'last');
end
end
5 and 6th line are giving the errors.
Thanks

 Risposta accettata

Rik
Rik il 27 Mag 2020

0 voti

If you store output of the find function to a temporary variable, you will notice that the error occurs when that temporary variable is empty.
If you can't guarantee a non-zero value can be found you need to think about a mitigation. Do you want to store a NaN? A zero?

4 Commenti

Sunil S Hosakoti
Sunil S Hosakoti il 27 Mag 2020
Modificato: darova il 29 Mag 2020
Yes, I want to enforce the first and last non-zero row to 'zero (0)' to remove the edge effects or the artifact. I have attached images in transition (1st image and 18th image) which will tell you about the edge effects i'm mentioning about. Thanks
What is it exactly you want to remove? What do you want to measure? Those bright parts look much wider than a single pixel.
You could prevent the error in your original post with this line, but I doubt that will get you the result you want.
if ~any(EffectiveDivergence(:,k,j)),continue,end
Sunil S Hosakoti
Sunil S Hosakoti il 28 Mag 2020
Modificato: Sunil S Hosakoti il 29 Mag 2020
I want to remove the encircled parts which is actually a transient efffect (basically an artifact). I am only interested in what happens beneath that tip. So in every frame i want to enforce that first non-zero occuring row to zero. I have about 200 frames for each experiment. If i don't, that single horizontal line in the first image develops into a huge band which is undesirable.
It was a problem due to the presence of NaN in the array. Got it sorted out.
Thanks a lot for your time and help.

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by