launching MATLAB
where on campus
professional price, many companies,
student version about $100
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
interpolation as in MAPLE that adaptively adds more points...)
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
addpath c:\temp
arrange windows to be nonoverlapping: command, editor, grafix
download (save to disk, c:\temp) data-file current.m
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? (c_{k})
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....