MATLAB: Pre allocating vector for loop pre-allocating Can any one tell how to pre allocate c1? thanks for ii = 1:length(a11); c1=cross(L1(1,:),a11(ii,:)); end Best Answer c1 = cell(numel(a11),1); % before loop use numel instead of lengthc1{ii} = ... inside loop Related SolutionsMATLAB: Reshape loop resulted cell array result = cell2mat(c1(:))'; MATLAB: Pre allocating triple loops n = numel(L);c = cell(n,n,45);for ii = 1:n for jj = 1:n for kk = 1:45 c{ii,jj,kk} = cross(L1(ii,:),a{jj}(kk,:)); end end end Related QuestionEditing inside cells arrayPre-allocating structuresGiven two 1 x n cells namely, C1 and C2, how to create a new cell C3 such that C3 = {C1(1) C2(1) C1(2) C2(2) C1(3) C2(3) … } using a for loopElement-wise creation of Matrix
Best Answer