%plot cosine wave

F=1e6 % frequency (Hz)
w = 2*pi*F % angular frequency (rad/sec)
T = 1/F % period (sec)
NT = 4 % how many periods to plot
dt = T/50 % 50 samples per period
NP = round(NT*T/dt) % number of samples to plot, total

A = 12 % amplitude (volts, amps, whatever you are plotting)
phideg = -30 % degrees
phi = phideg*pi/180 % convert to radians

for n=1:NP;
t(n) = (n-1)*dt; % time (sec)
v(n) = 12*cos(w*t(n)+phi) ; % voltage (V)
end

figure;
plot(t,v);
xlabel('time (sec)')
ylabel('voltage (V)')