error when using 'find' function
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sunil S Hosakoti
el 27 de Mayo de 2020
Comentada: Sunil S Hosakoti
el 3 de Jun. de 2020
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
0 comentarios
Respuesta aceptada
Rik
el 27 de Mayo de 2020
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 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!