Subscripted assignment dimension mismatch.

Hello, I am attempting to separate a large matrix into two parts for kernel formation for clustering with a kernel k-means algorithm. While I would ordinarily jus reshape it into a third dimension, this option is impossible given that the number of columns in the matrix in question is odd (24021). I have been unable to perform any of the things that I have seen before, such as indexing. Below is the method I tried, which returned the above error message.
EDU>> for n=1:24041
if n<=12021
split{1}(n)=test(:,n);
elseif n>12021
split{2}(n-12021)=test(:,n)
end
end
Subscripted assignment dimension mismatch.
If anyone can tell me what is going on, I would greatly appreciate it. Thanks in advance.

 채택된 답변

Walter Roberson
Walter Roberson 2013년 1월 12일

0 개 추천

split{1} = test(:,1:12021);
split{2} = test(:,12022:end);

댓글 수: 1

Jacob Moses
Jacob Moses 2013년 1월 12일
This worked perfectly, and was easiest for me to understand. Thank you so much!

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

추가 답변 (1개)

José-Luis
José-Luis 2013년 1월 12일
편집: José-Luis 2013년 1월 12일

0 개 추천

You are probably trying to assign a matrix to a scalar:
split{1}(n)=test(:,n);
split{1}(n) is most likely a scalar
test(:,n) is probably a column vector

댓글 수: 3

Walter Roberson
Walter Roberson 2013년 1월 12일
test(:,1) would have to be a row vector.
José-Luis
José-Luis 2013년 1월 12일
No, it is a column vector as far as I understand it.
José-Luis
José-Luis 2013년 1월 12일
Now I see what you meant. I need some coffee.

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by