Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Divide by 2 every second double column without losing structure of cell array

1 回表示 (過去 30 日間)
Nik Rocky
Nik Rocky 2020 年 6 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello, I have a big cell array, every Cell has 2 columns. Hove can I divide by 2 every second double column without losing structure of cell array?
Test =
1×189 cell array
Columns 1 through 5
{14×2 double} {9×2 double} {3×2 double} {4×2 double} {7×2 double}
Columns 6 through 10
{5×2 double} {8×2 double} {7×2 double} {12×2 double} {6×2 double}
Columns 11 through 15
.......
For example:
1.11 490
1.14 492
1.17 488
1.20 484
to
1.11 245
1.14 246
1.17 244
1.20 242
somethink like this, but its a wrong code
Test{1,:}=Test{1,{:}/2}
Thank you!

回答 (2 件)

Deepak Gupta
Deepak Gupta 2020 年 6 月 18 日
Below program should work for your problem:
test = {[10, 15], [20, 30]};
for index = 1: length(test)
test{index}(:, 2) = test{index}(:, 2)/2;
end

Vinayak Mohite
Vinayak Mohite 2020 年 6 月 18 日
Hi Nikita,
I am assuming that you want to divide the second column in the table by 2.
Here is the way to do it.
Test{:, 2} = Test{:, 2}./2

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by