Empty matrix: 0-by-1

4 visualizaciones (últimos 30 días)
laser laser12
laser laser12 el 13 de Jul. de 2015
Comentada: Bachtiar Muhammad Lubis el 25 de Mayo de 2019
Dears, I have a problem. I try to find a cretin value (Eexc) obtained from equation in an input array(E).
[ro,co]=find(E==Eexc)
i have got this error message. Empty matrix: 0-by-1
Regards,

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 13 de Jul. de 2015
A=[1 2 3]
find(A==5)
The result is
ans =
Empty matrix: 1-by-0
Because 5 is not found in A

Star Strider
Star Strider el 13 de Jul. de 2015
Could be a problem in floating-point approximation inaccuracies, the result of expressing decimal numbers in binary format.
See if:
[ro,co]=find(abs(E-Eexc) <= 1E-8)
works. This introduces a tolerance to the comparison. You may need to experiment with it to get the result you want.
  4 comentarios
Image Analyst
Image Analyst el 13 de Jul. de 2015
Most of us know about that min() trick. It would have been good to share the larger context of what you wanted (finding the closest index) in the first place rather than having us try to fix some approach that you thought of that turned out to be not very good. However, it still needs fixing. It's not good to have ro in both outputs of min. You should do it like this:
[minValue, indexOfClosestValue] = min(abs(E-Eexc)); %index of closest value
closestEValue = E(indexOfClosestValue);
Bachtiar Muhammad Lubis
Bachtiar Muhammad Lubis el 25 de Mayo de 2019
I face the same issue like him. I have codes that look like:
load template;
comp=[];
for n=1:num_char
sem = corr2(template{1,n},img);
comp = [comp sem];
end
vd = find(comp==max(comp));
vd return Empty matrix: 1-by-0. In my case i only need a value. If i use abs() function the velue would be integer while i need rill number (i.e. either 1 or 0,5 etc.) And. Also if i use 1E-8 it would be return more than one value while i only need a value. Can you guys help me to solve my problem please.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by