I have some values stored in a matrix, e.g.
Matrix = [1,4,6]
and a cell array, such as:
CellArray{1} = [0,0,1,0]
...
CellArray{4} = [0,0,0,0,0,0,0,1]
...
CellArray{6} = [0,0,1,1,1,0]
For each element of the Matrix in CellArray, i.e. CellArray{Matrix(1:end)}, I want to substitute the ones with zeros. So far, I've thought of:
[Output] = cellfun(@(x) subs(x,1,0),{CellArray{Matrix}},'UniformOutput',false)
though, the ouput is not as I wanted...
Since the example suggests that CellArray only contains vectors with 0s and 1s (and the question does not specify the opposite), may I suggest
Output = cellfun(@(x)zeros(1, numel(x)), CellArray(Matrix), 'uniformoutput', 0)
which really just replaces the entry with a zero vector of appropriate length.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With