필터 지우기
필터 지우기

making a 341x341 matrix from a 465124x1 matrix.

조회 수: 1 (최근 30일)
Jeroen
Jeroen 2012년 5월 21일
Hello everybody,
I have a matrix that is 465124x1. From this matrix I want every 341 values put in another matrix. so the values from 1-341 is the first column and than the values from 342-683 is the second column etc. This should yield a 341x341 matrix.
It gives a 341x341 matrix but just with the values from 1-341 from the orginal matrix. Here is my code:
for i = 1:341:465124
for p = 1:1:341
a = i+340;
kolom(:,p) = value(i:a,1);
end
end
I do not know what i am doing wrong so please help.
Thank you!
  댓글 수: 2
Titus Edelhofer
Titus Edelhofer 2012년 5월 21일
But 341*341 gives 116281, not 465124 ...?
Jan
Jan 2012년 5월 21일
Titus, this is a surprising detail.

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

채택된 답변

Andreas Goser
Andreas Goser 2012년 5월 21일
Sounds like you are looking for the RESHAPE command.
  댓글 수: 1
Jeroen
Jeroen 2012년 5월 21일
okay thank you I tried the reshape function and it works now

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

추가 답변 (1개)

Thomas
Thomas 2012년 5월 21일
465124/(341*341)=4
You will get 4 341*341 matrices from one 465124 matrix..
You could try
% a is your 465214x1 matrix
b=reshape(a,341,341,[]) % this will give u a 3 dimensional matrix of size (341*341*4)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by