Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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