Double the values of an 2D array
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I have a 2D array called Numerical_3, I want to double the values of its rows, except the first row. I have attached the picture

This is the code I am using
Numerical_3 = cell2mat(Numerical_2)
P1 = Numerical_3( :,1);
P2 = Numerical_3( :,2)
P1(2:end-1) = 2*P1(2:end-1);
P2(2:end-1) = 2*P2(2:end-1);
But it is not giving me correct results..
I want to double the values from row 2 till end,
does anybody know?
댓글 수: 0
채택된 답변
KSSV
2020년 8월 17일
Let A be your n*2 matrix. To double from second row use:
A(2:end,:) = 2*A(2:end,:) ;
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!