Borrar filtros
Borrar filtros

Error with indexing 'First argument must be numeric or logical'

1 visualización (últimos 30 días)
M & z are both 10x1300 cell arrays of same size
Columns 1296 through 1300
[1×23 double] [1×23 double] [1×29 double] [1×23 double] [1×25 double]
[1×27 double] [1×25 double] [1×25 double] [1×25 double] [1×27 double]
[1×21 double] [1×25 double] [1×27 double] [1×27 double] [1×25 double]
[1×27 double] [1×29 double] [1×29 double] [1×25 double] [1×23 double]
[1×27 double] [1×25 double] [1×23 double] [1×27 double] [1×27 double]
[1×27 double] [1×27 double] [1×23 double] [1×21 double] [1×23 double]
[1×25 double] [1×29 double] [1×27 double] [1×27 double] [1×27 double]
[1×27 double] [1×21 double] [1×21 double] [1×29 double] [1×27 double]
[1×25 double] [1×25 double] [1×25 double] [1×21 double] [1×27 double]
[1×23 double] [1×25 double] [1×25 double] [1×25 double] [1×23 double]
index=cellfun( @(Z) find(abs(Z-1)<0.005), z, 'uniform', 0);
index results Columns 1297 through 1300
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[ 25] [1×2 double] [1×2 double] [1×2 double]
[1×2 double] [1×2 double] [1×2 double] [1×2 double]
[1×2 double] [1×2 double] [1×2 double] [1×2 double]
[1×0 double] [1×0 double] [1×2 double] [1×2 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
[1×0 double] [1×0 double] [1×0 double] [1×0 double]
Result=cellfun(@(IDX) min(M(IDX)), index, 'uniform', 0); < error occurs on this line finding minimum of M at z=1, how do i fix this?
Is it because of the zeros in index?
  1 comentario
Joseph Lee
Joseph Lee el 21 de Nov. de 2017
cellfun(@(m, IDX) min(m(IDX)), M, index, 'uniform', 0)
Tried this code but got another error: Subscripted assignment dimension mismatch.

Iniciar sesión para comentar.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 21 de Nov. de 2017
Result = zeros(size(index));
t = ~cellfun(@isempty,index);
Result(t) = cellfun(@(mm,ii)min(mm(ii)),M(t),index(t));
  2 comentarios
Joseph Lee
Joseph Lee el 21 de Nov. de 2017
Editada: Joseph Lee el 21 de Nov. de 2017
I got the same error:Subscripted assignment dimension mismatch.
I think i know why, the minimum im looking for is not for each cell array but for all the cells, the result should give only one single value which i am storing into a matrix while increasing the find(abs(Z-1)<0.005) to find(abs(Z-2)<0.005) and so on
Do i just add min?
Result(t) = min(cellfun(@(mm,ii)min(mm(ii)),M(t),index(t)));
Joseph Lee
Joseph Lee el 21 de Nov. de 2017
This does not seem to work. I will open another question to be more specific

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices 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