필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

concatenate a vector in column-major order

조회 수: 1 (최근 30일)
OLUBUKOLA ogunsola
OLUBUKOLA ogunsola 2016년 6월 2일
마감: MATLAB Answer Bot 2021년 8월 20일
I am trying to solve a problem where the elements of a vector is compared to something and if found true the location of the element (say(1,2)) is output into another vector in a column-major order . my problem is that the vector returns the location of the last element, it overrides the elements before it instead of concatenating it. e,g if the locations of the elements are (1,2) (3,2) (4,1). it returns only (4,1). how do I make it to concatenate and how do I set it to column-major order?
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 2일
Your question is not clear, post your code, you can also, illustrate with an example

답변 (2개)

OLUBUKOLA ogunsola
OLUBUKOLA ogunsola 2016년 6월 2일
indexes=[]; for ii= 1:size (X,1); for jj = 1: size (X , 2); if X(ii , jj)< ii*jj; indexes = {ii ,jj}; end end end

Jos (10584)
Jos (10584) 2016년 6월 2일
X = randi(20,6,4)
[ii,jj] = ndgrid(1:size(X,1), 1:size(X,2))
tf = X < ii.*jj
ii(tf)
jj(tf)
  댓글 수: 5
OLUBUKOLA ogunsola
OLUBUKOLA ogunsola 2016년 6월 4일
im pasting the code again because it was jumbled together
function indexes = small_elements ( X)
indexes=[];
for ii= 1:size (X,1);
for jj = 1: size (X , 2);
if X(ii , jj)< ii*jj;
a=[ii jj];
indexes=[indexes; a];
end
end
end
Jos (10584)
Jos (10584) 2016년 6월 4일
Without an input, how can we know your code is incorrect?

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by