I have a big cell array A=cell(a,b,c,d) and a row vector B with dimensions 1-by-b.
I want to build a loop in MATLAB that does the following:
for i=1:n
B = Calculate_row(input1,input2) %this is a function that creates my B row
A{a,:,c,i} = B(:)
end
anyway if I try to do A{a,:,c} = B(:) I receive the following error:
Expected one output from a curly brace or dot indexing expression, but there were b results.
And if I try to do A(a,:,c) = B(:) I receive the following error:
Conversion to cell from double is not possible.
Is there a way to do this? (I know a less elegant way that probably works would be to assign each value to the cell separately, but I would prefer not to do it).
A(a,:,c) = {B(:)}. However, the way you callCalculate_row(if that is indeed how you are calling it) is really bad practice. Never call a script from another script, make sure you only call functions. AdaptCalculate_rowto be a function that might look something likeB = Calculate_row(input1, input2,...)ias an index somewhere in the assignment - furthermoreAhas 4 dimensions, but you are only giving 3 dimensions in the assignment. Did you want to do thisA{a,:,c,i} = B(:)? (just guessing). Please give a value for the 4th dimension and try the assignment again :-)