I'm struggling with the rows index of the matrix.
First I have Matrix A which is 1125 X 30 dimensions. I want to initialize Matrix B as 10 X 30, first as zeros and then matrix B takes the first ninth rows of matrix A, and keep its last rows as zeros. How can I do that?

댓글 수: 6

James Tursa
James Tursa 2015년 4월 3일
편집: James Tursa 2015년 4월 3일
What is "... first ninth rows ..."? The 1st through the 9th? The 1st and 9th only? Every 9th row? Or what?
And where exactly in B do you want these rows of A to appear?
Hello Matlab
Hello Matlab 2015년 4월 3일
The 1st through the 9th
the cyclist
the cyclist 2015년 4월 3일
This is not perfectly clear to me. What is the final size of B?
Hello Matlab
Hello Matlab 2015년 4월 3일
B is still 10X30, but I want the values of The 1st through the 9th of A to be assigned to B
James Tursa
James Tursa 2015년 4월 3일
Where in B do you want these values of A to be assigned?
Hello Matlab
Hello Matlab 2015년 4월 3일
편집: Hello Matlab 2015년 4월 3일
The 1st through the 9th rows also

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

 채택된 답변

James Tursa
James Tursa 2015년 4월 3일
편집: James Tursa 2015년 4월 3일

1 개 추천

Is this what you want?
B = zeros(10,30); % initialize Matrix B as 10 X 30, first as zeros
B(1:9,:) = A(1:9,:); % B takes the first ninth rows of matrix A

댓글 수: 1

Hello Matlab
Hello Matlab 2015년 4월 3일
Thanks so much. Now I get it, I was assigning only the rows, and forgot to put for columns (:).

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2015년 4월 3일

댓글:

2015년 4월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by