How to change CELL components value?

42 次查看(过去 30 天)
How can we change the values of a cell component? I mean for example, A{i}.
For example when I want to divide all the values of a cell by 2, the usual math doesn't work:
A{i}=A{:}/2
or A=A/2
none of them works.
what shall I do?
thanks
Steven

采纳的回答

Wayne King
Wayne King 2013-12-28
A = cell(2,1);
A{1} = randn(100,1);
A{2} = randn(100,1);
A{1} = A{1}/2;
A{2} = A{2}/2;
Or if you want to do it to all the elements in the cell array
out = cellfun(@(x) x/2,A,'uni',0);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by