To achieve this, you need to loop through all elements of the cell array C and set the values to zero for all indices except for the specified ones (i=1 and j=1). You want to retain the original sizes of the matrices but replace their values with zeros.
Here's a MATLAB script to do this:
% Example setup: create a sample cell array C with nested cell arrays
C = cell(3, 3);
for i = 1:3
for j = 1:3
C{i, j} = cell(1, 3);
for k = 1:3
C{i, j}{k} = rand(i + 1, j + 1); % Random matrices of different sizes
end
end
end
% Display original C
disp('Original C:');
disp(C);
% Apply the zeroing operation
for i = 1:size(C, 1)
for j = 1:size(C, 2)
% Skip the specified indices (i=1 and j=1)
if ~(i == 1 && j == 1)
% Loop through each nested cell array
for k = 1:length(C{i, j})
% Get the size of the current matrix
[k1, k2] = size(C{i, j}{k});
% Set all elements to zero
C{i, j}{k} = zeros(k1, k2);
end
end
end
end
% Display modified C
disp('Modified C:');
disp(C);