Finding values of specific range from table row or column
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
yaser arafat kazi
el 25 de Jul. de 2019
Comentada: yaser arafat kazi
el 28 de Jul. de 2019
Hi,
I'm having the Table whose first column is as A = [12345 NaN NaN NaN NaN 457 NaN NaN NaN 785 NaN NaN NaN NaN NaN NaN 74502]
I want to select range as 12345 to NaN (shown in bold) , 457 to NaN and so on.
Please guide.
0 comentarios
Respuesta aceptada
Stephen23
el 26 de Jul. de 2019
Editada: Stephen23
el 26 de Jul. de 2019
>> A = [12345 NaN NaN NaN NaN 457 NaN NaN NaN 785 NaN NaN NaN NaN NaN NaN 74502].'
A =
12345
NaN
NaN
NaN
NaN
457
NaN
NaN
NaN
785
NaN
NaN
NaN
NaN
NaN
NaN
74502
Method one: accumarray:
>> C = accumarray(cumsum(~isnan(A)),A,[],@(v){v});
>> C{:}
ans =
12345
NaN
NaN
NaN
NaN
ans =
457
NaN
NaN
NaN
ans =
785
NaN
NaN
NaN
NaN
NaN
NaN
ans =
74502
Method two: mat2cell:
>> X = diff(find([true;diff(isnan(A))<0;true]));
>> C = mat2cell(A,X,1);
>> C{:}
ans =
12345
NaN
NaN
NaN
NaN
ans =
457
NaN
NaN
NaN
ans =
785
NaN
NaN
NaN
NaN
NaN
NaN
ans =
74502
Más respuestas (1)
Shreya Shetty
el 26 de Jul. de 2019
Editada: madhan ravi
el 26 de Jul. de 2019
Go through this. It might help you
1 comentario
madhan ravi
el 26 de Jul. de 2019
Editada: madhan ravi
el 26 de Jul. de 2019
No, indices should be determined by the code and not by giving it manually.
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!