echo on
%to display the commands
clear
a=5;b=-1;
c(1)=a;c(2)=sqrt(b);
who
whos

%             LOAD AND SAVE VARIABLES
clear
x=linspace(0,2*pi)
y=cos(x);z=sin(x);
save trigvar

whos
clear
whos
load('trigvar')
whos

save trigvar x y
clear
who
load trigvar
whos
%             CREAT ASCII FILE
xy=[x',y'];
save trigvar.txt xy -ascii
type trigvar.txt
clear
who
%             CAN ONLY LOAD FILE WITH COLUMNS OF EQUAL LENGTH
d=load('trigvar.txt')
x=d(:,1)
y=d(:,2);
plot(x,y)
%             SETTING THE PATH
help path
help addpath

%             LOW LEVEL INPUT/OUTPUT
help fopen
help fprintf
help fscanf
help fgetl
clear

x=linspace(0,2,34);
r=rand(1,34);
y=sin(x) + r;
fp=fopen('trial','w')
fprintf(fp,'Day    Rainfall\n')
fprintf(fp,'%5.1f %8.3f \n',x,y)
fclose(fp)

type trial

clear
who

fp=fopen('trial','r')

h=fgetl(fp)
data = fscanf(fp,'%f',[34,2])

fclose(fp)

fp=fopen('trial','r')
h=fgetl(fp)
data = fscanf(fp,'%f',[36,2])
fclose(fp)

fp=fopen('trial','r')
h=fgetl(fp)
data = fscanf(fp,'%f')
fclose(fp)

n=length(data)
data2=reshape(data,length(data)/2,2)

plot(data2(:,1),data2(:,2))
