MATLAB: The figure is not showing after the plot is runned

plotting

Hi, I'm trying to plot these values over the year ( in days). I saved each value into a matrix with their respective variable and it comes out as a 1 x 366 matrix. I tried plotting the G0 values over the year (n in days), but no graph comes out when the code is finished.
Gsc = 1367;
phi = 33;
alpha = -117;
for n = 1.0:1:366
delta(n) = 23.45*sind(360 * ((284+n)/365));
w(n) = ((sind(alpha)-sind(delta(n))*sind(phi))/(cosd(delta(n))*cosd(phi)));
G0(n) = Gsc*(1 + 0.033*cosd((360*n)/365))*(cosd(phi)*cosd(delta(n))*cosd(w(n)) + sind(phi)*sind(delta(n)));
figure(1)
plot(n, G(n))
end

Best Answer

Gsc = 1367;
phi = 33;
alpha = -117;
figure(1)
hold on
for n = 1.0:1:366
delta(n) = 23.45*sind(360 * ((284+n)/365));
w(n) = ((sind(alpha)-sind(delta(n))*sind(phi))/(cosd(delta(n))*cosd(phi)));
G(n) = Gsc*(1 + 0.033*cosd((360*n)/365))*(cosd(phi)*cosd(delta(n))*cosd(w(n)) + sind(phi)*sind(delta(n)));
plot(n, G(n))
end
No loop required, use:
Gsc = 1367;
phi = 33;
alpha = -117;
n = 1.0:1:366 ;
delta = 23.45*sind(360 * ((284+n)/365)) ;
w = ((sind(alpha)-sind(delta)*sind(phi))./(cosd(delta)*cosd(phi)));
G = Gsc*(1 + 0.033*cosd((360*n)/365)).*(cosd(phi)*cosd(delta).*cosd(w) + sind(phi)*sind(delta));
plot(n,G) ;