Quick summary of intro to MATLAB, Sept.7:
• Exercises (especially for anyone who came late, missed the class):
• Work thru every detail in this page -- sit down at a computer w/ MATLAB!!!
type in the commands in BOLD, and make sure you understand what each
does -- in some cases it may be easier to replace 512 by 5 to first understand
a little example. Whenever unsure, read the help page (eg. help clf)
• Review calculus I -- the defintion of the integral as a limit of Riemann sums and
make sure you completely understand how the calculation of ck below works.
• Then  continue the exercise and calculate the first 10 coefficients, i.e. c-10 to c10,
and plot the successive approximations.
Try this on your own, or use the sample sep7.m as a naive template....
fast numerics (as opposed to symbolic CAS=computer algebra systems)
excellent grafix
origin early 1980s,
basic DOS-like interface, also modern object oriented programming

launching MATLAB
where on campus
professional price, many companies,

3+5 ENTER
philosophy of absolutr minimal typing
only one basic data structure: matrices (and modern objects)
for anyone w/o lin alg experience, think of rectangular tables of numbers

A=rand(5,5);
A:=rand(5,5)
A=rand(5,5)
det(a)
det(A)
pi
Pi
PI
note: case sensitivity
compare role of : versus ; and = versus :=

T=[1:8]
T=[1:8]'
Y=[0 7  0 9  2 0 0 0]'
plot(T,Y,'cr')

plot only the points provided, make table, conect dots (no fancy

help plot (as opposed to ?)

demo
buttons and slide show are created/programmed in MATLAB!
try out grafix, visualization -- note tyhe extremely compact code to create these!
try out matrices, basic operations -- need to learn all these!!!

helpdesk
search for functions, e.g. fft
scroll down to example, block, and CNTRL C,
back in command window
edit
in editor/debugger:
CNTRL V
script (versus function), m-files
save script file in TEMP as fft1.m
edit script (delete or comment out the comments....)
save

back in command window
fft1
undefined, need to define path
path

arrange windows to be nonoverlapping: command, editor, grafix

edit the script, to use our own data
i.e. replace defn's of t, x, y by:
A=current;
t=A(:,1);
y=A(:,2);
plot(t,y);
pause
leave remainder as is, or change number of points included in 2nd plot
execute script from command window fft1
interpret plots -- what do these show? (ck)

observation:
just a very few lines of simple code to define data, fft extremely fast
this is what professionals use .... not integration by parts!!!

in our class, want to get a little feel for what is behind the method
(very naive numwerical integration, no effort made for speed, also
trying to use very  basic commands for beginners)

clear all
start from scratch in new script
% first enter the data
A=current;
t=A(:,1);
y=A(:,2);
N=size(A,1)
T=t(N)-t(1)
% technically this should be T=(t(N)-t(1))*N/(N-1)
plot(t,y,'b-');
pause
% calculate the first integral -- the average value!
c0=sum(y)/N
% In general one should carefully discuss whether the period is N or (N-1)
% and thus include both / exclude one of the endpoints....
% create values of cos/sin/exp -- start from inside out!
% -- note no fuss about complex numbers.... they are the standard!
%  e1 = [1 : 512]'
%  e1 = 2*pi*i*/512*[1 : 512]'
e1 = exp( - 2*pi*i/512*[1 : 512]')
em1 = exp(  2*pi*i/512*[1 : 512]')
% check graphically, either way that this appears OK (one period)
plot(e1)
pause
plot([1:N]',real(e1),[1:N]',imag(e1))
% multiply function values and values of exponential, and integrate the product
c1=(1/N)*sum(y.*e1)
cm1=(1/N)*sum(y.*em1)
% form the approximant and overlay plot
y1=c0+c1*em1+cm1*e1;
%clear the grafix, and set to overlay=mode
clf
plot(t,y,'b-');
hold on
plot(t,y1,'r-');

Continue on your own -- or use sep7.m  as a reference....