Double the values of an 2D array

2 ビュー (過去 30 日間)
Chris Dan
Chris Dan 2020 年 8 月 17 日
回答済み: KSSV 2020 年 8 月 17 日
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?

採用された回答

KSSV
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 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by