One way is to make F a cell array. Notice that in the loop, I am accessing F using curly brackets instead of parentheses. Each F{i} is an array.
Is there any reason to keep them as separate arrays? You could also just make F one array, which is 101x181.
[Apologies for any little syntax errors here. I could not actually run your code without knowing your constants.]
theta=-20*pi/180:pi/180:80*pi/180;
phi_vec = 0:pi/180:pi;
Nphi = numel(phi_vec);
F = cell(Nphi,1);
for np = 1:Nphi
phi = phi_vec(np);
gamma=phi+BOC;
C2=((rmax^2)-(rmin^2))/((cos(gamma+thetamin)-cos(gamma+thetamax)));
C1=(rmax^2)+C2*cos(gamma+thetamax);
a=((C1+C2)^(1/2)+(C1-C2)^(1/2))/2;
b=C2/(2*a);
r=sqrt(C1-C2*cos(gamma+theta));
F{np}=(r/b*a)*m*g*OC*(cos(theta)/sin(gamma+theta));
end
Best Answer