Number in a cell to a row number in loop.

1 visualización (últimos 30 días)
Neje
Neje el 3 de Abr. de 2018
Comentada: Neje el 5 de Abr. de 2018
Hello! I have a matrix containing numbers [8 88 67 74] and so on, and I want matlab to take these numbers as 'row numbers' of an another matrix. How should I do this?
  2 comentarios
Stephen23
Stephen23 el 3 de Abr. de 2018
@Neje: what would the expected output be?
Neje
Neje el 3 de Abr. de 2018
I want to perform row operations on these numbers. But do not want to put these numbers manually. (they are already present in an another matrix)
if true
%code
for i=8,88,67,74
end

Iniciar sesión para comentar.

Respuesta aceptada

Bob Thompson
Bob Thompson el 3 de Abr. de 2018
If you're just looking to use those values as row selection you can enter them as the index of your value:
for k = 1:length(rownums);
results = data(rownums(k),:); % Include your operations here, but the indexing for your data should call
% the entire row specified by the kth value of your first matrix of row
% numbers.
end
  2 comentarios
Neje
Neje el 4 de Abr. de 2018
Thanks! It works :)
Neje
Neje el 5 de Abr. de 2018
But it throws as an error for 'data' function as follows.
Undefined function 'data' for input arguments of type 'double'.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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