Display a new matrix
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
Hi there, if I have a matrix A of MxM and another matrix B column of Mx1. And a variable p.
When I say p = 1, I want to display a matrix C formed from the first line of the matrix A, to which I also add the first line from B.
Ex:
A = [ 1 2 3 4; 
        5 6 7 8;
       9 10 11 12;
       13 14 15 16 ]
B = [  0; 
         1;
         1;
         0 ] 
p = 1 --> C = [1 2 3 4 0]
p = 2 --> C = [1 2 3 4 0; 5 6 7 8 1]
p = 3 --> C = [1 2 3 4 0; 5 6 7 8 1; 9 10 11 12 1]
A little help, please
댓글 수: 0
채택된 답변
  per isakson
      
      
 2020년 4월 11일
        
      편집: per isakson
      
      
 2020년 4월 11일
  
      This should do it:
>> p=1;
>> [A(1:p,:),B(1:p,:)]
ans =
     1     2     3     4     0
>> p=2;
>> [A(1:p,:),B(1:p,:)]
ans =
     1     2     3     4     0
     5     6     7     8     1
>> 
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

