You are writing to the element with index N and P, but their values are static and not effected by the loop. I assume, you want this:
vN = linspace(Phimin, Phimax, N)
for iN = 1:length(vN)
Phi = vN(iN);
G(iN)=Phi + BOC;
C2(iN)=Rcon ./ ((Ccon .* cos(G(iN))) + (Scon .* sin(G(iN))));
C1(iN)=Rmax^2 + (C2(iN) .* cos(G(iN) + Thetamax));
A(iN)= (sqrt(abs(C1(iN)+C2(iN))) + sqrt(abs(C1(iN)-C2(iN))))./2;
B(iN)=C2(iN) ./ (2.*A(iN));
vP = linspace(Thetamin, Thetamax, P);
for iP = 1:length(vP)
Theta = vP(iP);
F(iN,iP)= abs(((R(iP).*(M*g*L)) .*cos(Theta)) / ...
((A(iN).*B(iN)) .* sin(G(iN)+Theta)));
disp(F(iN,iP))
end
end
If this solves your problem, it can be made much faster: 1. Pre-allocate the vectors by zeros(1, length(vN)) and zeros(length(vN), length(vP)). And move all repeated calculation before the loops. E.g. the creation of vP, M*g*L.*cos(Theta) etc. But I'm not going to optimize your code, as long as I do not know, if it matchs your needs at all.
Best Answer