Number in a cell to a row number in loop.

조회 수: 1 (최근 30일)
Neje
Neje 2018년 4월 3일
댓글: Neje 2018년 4월 5일
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
Stephen23
Stephen23 2018년 4월 3일
@Neje: what would the expected output be?
Neje
Neje 2018년 4월 3일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Bob Thompson
Bob Thompson 2018년 4월 3일
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
Neje
Neje 2018년 4월 4일
Thanks! It works :)
Neje
Neje 2018년 4월 5일
But it throws as an error for 'data' function as follows.
Undefined function 'data' for input arguments of type 'double'.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by