I am trying to "map" a function over each cell in a cell array. For example, suppose that I have a cell array which is filled with vectors of the same length:
Now I wish to apply the built-in Matlab function "norm" to each element in the cell array and return the results in an array (a regular, numeric array/matrix). I tried the following:
But of course this does not give me what I really want; it gives me the following:
which is only the norm of the (1,1) element (note that sqrt(1.^2 + 1.^2) = 1.4142) and the norm of the (2,2) element (note that sqrt(4.^2 + 4.^2) = 5.6569). This is because in my code, by specifying M as 1:size(C,1) and N as 1:size(C,2), the function is only evaluated at (M,N)=(1,1) and (M,N)=(2,2).
Can you please help me to see how I can modify my code to take the norm of all the arrays stored in the cell array C?
Thanks in advance,
Carnegie Mellon University