HpfsDemo/about.m                                                                                    0100666 0001512 0000145 00000004553 06422472334 0014457 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        % This is the About selection


AboutFig=figure('Units','Normalized','Position',[.4 .35 .5 .55],...
	'MenuBar','none',...
	'Name','About The Rotating Vector Demonstration',...
	'NumberTitle','off','Resize','on','UserData',['graph']);

TextFrame=uicontrol('Style','frame','Units','normalized',...
	'Position',[.03 .52 .94 .45]);

CloseIt=uicontrol('Style','pushbutton','Units','normalized',...
	'Position',[.5 .53 .43 .07],'String','Close this Window',...
	'Callback','close');

l1=['This program was developed by Nabeel B. Azar '];
l2=['in a project directed by Wilson J. Rugh, with the support '];
l3=['of the National Science Foundation and the Kenan Fund for '];
l4=['Undergraduate Education at The Johns Hopkins University.  '];
l5=['This program is based on ideas from the 1971 movie '];
l6=['"Harmonic Phasors II," produced by William H. Huggins '];
l7=['at The Johns Hopkins University.'];
CreditText=[l1,l2,l3,l4,l5,l6,l7];
Credits=uicontrol('Style','text','Units','normalized',...
	'Position',[.05 .63 .87 .33],'ForeGroundColor','k',...
	'HorizontalAlignment','left','String',CreditText);

%-------------------------------------------

subplot(2,1,2)
axis ([-1 181 0 1])
axis off
hold on
global SpeedFactor
incr=round(3/SpeedFactor);
if incr==0
	incr=.5;
end

numvalues=180/incr +1;
deg=(2*pi)/360;
points=zeros(2,numvalues);
xval=zeros(1,numvalues);
t=0;
for t=1:500		%  Up to 500 vectors
			%  if they wait long enough !!!


yold=0;
xold=0;
cntr=0;
line([0 0],[0 .8],'Color','b','EraseMode','none')
line([0 180],[.8 .8],'Color','b','EraseMode','none')
line([180 180],[.8 0],'Color','b','EraseMode','none')

	for x=0:incr:180;
		cntr=cntr+1;
		nvalue=[(1/(2*t-1)) * sin((2*t-1)*deg*x)];
		points(t,cntr)=nvalue;
		%------------------------
		% To draw the points		
		yval(cntr)=sum(points(:,cntr));		
		PrevLine(t,cntr)=line([xold, x],[yold, yval(cntr)],...
		'EraseMode','xor');
		yold=yval(cntr);
		xold=x;
		drawnow


	end
	%  We want to pause if fewer than 7
	% vectors.  If more, we want to hurry
	% up and watch it change to the square wave
	
	if t < 7
		pause(1)
	end

%-------------------------------
%  Is the figure window still there?
%  If not, it has been closed and
%  we don't need to continue execution
%
if gcf~=AboutFig
	break
end
%
%-------------------------------

	if t~=1
		delete(PrevLine(t-1,:))
	end

	set(PrevLine(t,:),'Color',[.5 .5 .5])



end
%----------------------------                                                                                                                                                     HpfsDemo/arrange.m                                                                                  0100666 0001512 0000145 00000003037 06422467530 0014762 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function arrange(arg)

Graphs=findobj('UserData',['graph']);
%If there are no graphs, do nothing
if Graphs==[]
	return
end

NumGraphs=size(Graphs,1);
%-------------------------------------------------
%	Key
%
%10	Arrange the graphs
%20	Minimize the Graphs , Can't do this yet
%30	Close the Graphs





%**************************************************
if arg==10
%**************************************************

%This function arranges the graphs
%neatly on the screen


%To see if numgraphs is a perfect square
%If so, then it's easy
%If not, it will get messy...

if sqrt(NumGraphs)==round(sqrt(NumGraphs))
	Grws=sqrt(NumGraphs);
	Gclms=Grws;

else
	closest=NumGraphs;
	while sqrt(closest)~=round(sqrt(closest))
			closest=closest-1;
	end
	
Grws=sqrt(closest);
Gclms=Grws;
	while Grws*Gclms<NumGraphs
		Gclms=Gclms+1;
	end

end

%***************************************
%To compute the size of each figure

width=1/Gclms;
height=.86/Grws;
%---------------------------------------
%To place each graph on the screen
%The Grws:-1:1 helps to place the graphs in
%the order they were created.
i=1;
for r=Grws:-1:1
	BottomSpace(r)=(r-1)*height;

	for c=1:Gclms
		LeftSpace(c)=(c-1)*width;
		
		set(Graphs(i),'Units','normalized',...
			'Position',[ LeftSpace(c), BottomSpace(r)+.02,...
			width, height]);
		i=i+1;
		if i>NumGraphs
			return %It's over!
		end

	end
end
%***************************************
%***************************************

elseif arg==30
	delete (Graphs)
	return
end	%The end of all the elseifs...
	%Should be the last line of code


                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 HpfsDemo/demo.m                                                                                     0100666 0001512 0000145 00000011153 06422467530 0014265 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function stwin(speed)
clear global % Need to keep the speed 
		% variable for later

%Set up window
close all
home

%***************************************
StartTime=cputime;

%****************************

Title=['The Harmonic Phasor Demonstration'];

%StartWindow=figure ('Units','normalized', 'Position',[eps,1-eps,1-eps, .001],...
StartWindow=figure ('Units','normalized', 'Position',[eps,.9,1-eps, .01],...
	'NumberTitle','off','Name',Title,'MenuBar','none',...
	'Resize','on');

%***************************************************
%The manual entry window

OwnValues=uimenu('Label','Own &Values','CallBack','vnv');

%---------------------------------------
%Contents of the Intro Samples menu

IntroMenu=uimenu('Label','&Cosines');
	uimenu (IntroMenu,'Label','&cos (x)','CallBack','maninp(2)');
	uimenu (IntroMenu,'Label','&sin (x)','CallBack','maninp(3)');
	uimenu (IntroMenu,'Label','cos (x + 40 degrees)',...
		'CallBack','maninp(4)');


%-----------------------------------------
%Contents of Other Waveforms Menu

OtherMenu=uimenu('Label','&Other Waveforms');

	OddHarm=uimenu(OtherMenu,'Label','&Square Wave');
		uimenu (OddHarm,'Label','&3 Harmonics:  sin(x) + (1/3)sin(3x)','Callback','maninp(5)');
		uimenu (OddHarm,'Label','&5 Harmonics:    "   +(1/5)sin(5x)','CallBack','maninp(6)');
		uimenu (OddHarm,'Label','&7 Harmonics:    "   +(1/7)sin(7x)','CallBack','maninp(7)');
		uimenu (OddHarm,'Label','&23 Harmonics:  "  ...  +(1/23)sin(23)','CallBack','maninp(8)');

	Impulse=uimenu (OtherMenu,'Label','&Impulse Train');
		uimenu (Impulse,'Label','&1 Harmonics','CallBack','maninp(9.03)');
		uimenu (Impulse,'Label','&4 Harmonics','CallBack','maninp(9.05)');
		uimenu (Impulse,'Label','&7 Harmonics','CallBack','maninp(9.08)');
		uimenu (Impulse,'Label','&15 Harmonics','CallBack','maninp(9.16)');

	Saw=uimenu (OtherMenu,'Label','Sa&wtooth');
		uimenu(Saw,'Label','&3 Harmonics','CallBack','maninp(10.03)');
		uimenu(Saw,'Label','&5 Harmonics','CallBack','maninp(10.05)');
		uimenu(Saw,'Label','&8 Harmonics','CallBack','maninp(10.08)');
		uimenu(Saw,'Label','&16 Harmonics','CallBack','maninp(10.16)');


%-----------------------------------------
%Miscellaneous Items

Space=['                 '];
BlankSpace=uimenu('Label',Space);
CleaningUp=uimenu('Label','C&leaning Up');
	uimenu (CleaningUp,'Label','&Arrange','CallBack','arrange(10)');
	uimenu (CleaningUp,'Label','&Close all','Separator','on','CallBack','arrange(30)');
About=uimenu('Label','&About','Callback','about','Interruptible','yes');
Exit=uimenu('Label','Exit','Position',[0],'CallBack','close all');
%-------------------

%***************************************

if nargin == 1
	global SpeedFactor
	SpeedFactor=speed;

else	% Then go on with the test

%***************************************
testfig=figure ('Units','normalized', 'Position',[.1, .15,.8, .75],...
	'NumberTitle','off','Name','Speed Calibration','MenuBar','none',...
	'Resize','off');
pause(1)
axis ([-5 185 -.8 1.2])
axis off
Please=['Please wait while the program speed is calibrated...'];
title(Please)
Wait=['In the meantime, enjoy this preview...'];
text('Units','data','Position',[40 0],'String',Wait)

hold on
incr=2;
numvalues=180/incr +1;
deg=(2*pi)/360;
points=zeros(2,numvalues);
xval=zeros(1,numvalues);

for t=1:5	%5 vectors

yold=0;
xold=0;
cntr=0;
line([0 0],[0 .8],'Color','b','EraseMode','none')
line([0 180],[.8 .8],'Color','b','EraseMode','none')
line([180 180],[.8 0],'Color','b','EraseMode','none')
	for x=0:incr:180;
		cntr=cntr+1;
		nvalue=[(1/(2*t-1)) * sin((2*t-1)*deg*x)];
		points(t,cntr)=nvalue;
		%------------------------
		% To draw the points		
		yval(cntr)=sum(points(:,cntr));		
		PrevLine(t,cntr)=line([xold, x],[yold, yval(cntr)],'EraseMode','xor'...
			);
		yold=yval(cntr);
		xold=x;
		drawnow


	end
	pause(1)
	%if t~=0
	if t>1

		delete(PrevLine(t-1,:))
	end
	set(PrevLine(t,:),'Color',[.5 .5 .5])



end
%----------------------------
TimeElapsed=cputime-StartTime
%----------------------------	
pause(3)
title('') % This is to clear the axis title
cla
Where=['You may now use the demo by making a selection from above.'];
text('Units','data','Position',[10 .5],'String',Where)
pause (4)
delete (testfig)
%***************************************
MyComputer=22;
TheirsVsMine=MyComputer/TimeElapsed; 
SpeedFactor=(round(10*TheirsVsMine))/10
global SpeedFactor
% The 10 is because I wanted 1 decimal of
% accuracy after I round

%**********************************************

end	% end of the speedfactor determination
%**********************************************

clear	% to clear the variables that we didn't
	% clear in the clear global at the 
	% beginning.  Done this way so that the
	% variable speed was retained
');

%---------------------------------------
%Contents of the Intro Samples menu

IntroMenu=uimenu('Label','&Cosines');
	uimenu (IntroMenu,'Label','&cos (x)','CallBack','maninp(2)');
	uimenu (IntroMenu,'Label','&sin (x)','CallBack','maninp(3)');
	uimenu (IntroMenu,'Label','cos (x + 40 degrees)',...
		'CallBack','maninp(4)');


%-----------------------------------------
%Contents of Other Waveforms MenHpfsDemo/grapher6.m                                                                                 0100666 0001512 0000145 00000010165 06422467531 0015062 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function yeah=grapher6 (woah)
%This function takes in the info from reader4
%and graphs it into the rotating and linear
%animated displays.


%Definitions and variable clearing follow

DEG=2*pi/360;

%Information from reader function

numvectors=woah (3,1);
MagArray(1:numvectors)=woah(1,1:numvectors);
FreqArray(1:numvectors)=woah(2,1:numvectors);
PeriodArray(1:numvectors)=woah(6,1:numvectors);
PhaseArray(1:numvectors)=woah(7,1:numvectors);
LCMPeriod=woah(5,1);
MagScale=woah(4,1);

%*******************************************
%First set up the top-left axis

tl=subplot (1,2,1);

	%Now we set up the axis
	set(tl,'Units','normalized','Position',[0 .1 .47 .85])

	axis([-MagScale-.2 MagScale+.2...
		-MagScale-.2 MagScale+.2])
	axis square	
	axis off
	% To add the zero lines
	line([-.1*MagScale .1*MagScale],[0 0],...
		'Color',[.5 .5 .5],'EraseMode','none');
	line([0 0],[-.07*MagScale .07*MagScale],...
		'Color',[.5 .5 .5],'EraseMode','none');
%Now the top-right axis

tr=subplot(1,2,2);
global Periods;	
	set(tr,'Units','normalized','Position',[.5 .1 .47 .85])
	axis ([0 (360*(LCMPeriod)*Periods)+30 ...
 		-MagScale-.2 MagScale+.2])
	axis square
	axis off
	% To add the zero line
	line([0 (360*(LCMPeriod)*Periods)+30],[0 0],...
		'Color',[.5 .5 .5],'EraseMode','none');

%*********************************************************

%This part will do the drawing

%-----------------------------------------------------------

%xvold and yvold are to hold the old trace points,
%so that we may connect the dots to the new
%trace points.  Here we calculate the starting point,
%avoiding an if statement in the loop.
%The if statement would be needed to prevent drawing
%a line from the point 0,0 to the first end point of
%the sum of the vectors; it would check to make sure
%that xvold or yvold ~=0
xvold=0;
yvold=0;
xold=0;
yold=0;

%*******************************
subplot(tl)
for iloop=1:numvectors

		[xnew,ynew]=pol2cart( ( DEG*PhaseArray(iloop) ), MagArray(iloop));

		%To plot the lines and alternate colors
		if rem(iloop,2)==1
			rothandle(1,iloop)=line([xold,xold+xnew],...
			[yold,yold+ynew],'EraseMode','xor','Color','r');
		else
			rothandle(1,iloop)=line([xold,xold+xnew],...
			[yold,yold+ynew],'EraseMode','xor','Color','g');
		end
		drawnow;
		pause (1);
		xold=xold+xnew;
		yold=yold+ynew;
	end %We've now drawn each vector once

pause (2);
xvold=xvold+xold;
yvold=yvold+yold;
delete(rothandle(1,1:numvectors));
%**********************************8
%**********************************

%The main loop.
%Now we catch each vector at a rate of 360/Sample times
%A total of 'Periods' periods are performed

global Sample
global SpeedFactor
AdjustedSample=Sample*SpeedFactor;
SRate=360/AdjustedSample;
for dloop=0:(SRate/max(FreqArray)):(360*LCMPeriod)*Periods


%Need to compute once for each frequency

%xold and yold are the "relative origin" for each
%additional vector, the are continually changing
%but start at the origin.
xold=0;
yold=0;

subplot (tl)	%The rotating graph will be in the
		% top left

	for floop=1:numvectors

		[xnew,ynew]=pol2cart( (dloop*DEG*FreqArray(floop) ) + ( DEG*PhaseArray(floop) ),...
						MagArray(floop));

		%To plot the lines and alternate colors
		if rem(floop,2)==1
			rothandle(1,floop)=line([xold,xold+xnew],...
			[yold,yold+ynew],'EraseMode','xor','Color','r');
		else
			rothandle(1,floop)=line([xold,xold+xnew],...
			[yold,yold+ynew],'EraseMode','xor','Color','g');
		end

		xold=xold+xnew;
		yold=yold+ynew;
	end %We've now drawn each vector once


	%Now to connect the dots
	line ([xvold,xold],[yvold,yold],'EraseMode','none')


%****************************************************
%The next part will draw the cartesian version
%----------------------------------------------------

subplot(tr)

line ([(dloop-(SRate/max(FreqArray))),dloop],[yvold,yold],...
					'EraseMode','none')


%**********************************************

	xvold=xold;  %This is to store the last point plotted
	yvold=yold;  %so we can connect the dots


	%Now to delete the rotating graph
	subplot (tl)
	delete(rothandle(1:numvectors))

	%Now to draw everything
	drawnow


%**********************************************
%Now to go on to the next degree
end
                                                                                                                                                                                                                                                                                                                                                                                                           HpfsDemo/labeler.m                                                                                  0100666 0001512 0000145 00000000745 06422467531 0014755 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function labeler(choice)
% This adds labels to the animation window

%	Option	What it does	Where in TitleInfo
%	1	inteligent

global LablHnd
global TitleInfo

%-------------------------------------------------
% To check the status of labeling
if TitleInfo(1,3)==1		% it's on
	set(LablHnd,'Label','&Labels are off')
	TitleInfo(1,3)=0;
elseif TitleInfo(1,3)==0	% it's off
	set(LablHnd,'Label','&Labels are on')
	TitleInfo(1,3)=1;
end

%-------------------------------------------------
                           HpfsDemo/maninp.m                                                                                   0100666 0001512 0000145 00000017165 06422467531 0014635 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function output=maninp (defaults)

global numvectors;



%Function takes in defaults, which contains
%the default values for the type of graph
%requested.  It accepts modifications, and then
%passes the end matrix in proper form
%[Mag, Freq, Phase;...] to mc 

%Here is what each default value means:
%	1000	Own Inputs
%	2	cos x
%	3	cos x
%	4	sin x + cos x
%	5	odd harm to 1/3,3
%	6	odd harm to 1/5,5
%	7	odd harm to 1/7,7
%	8	odd harm to 1/23,23
%	9.?	Impulse train functions
%	10.?	Sawtooth functions

%***********************************************


%-----------------------------------------
%  To determine if we should keep
%  the maninput screen up.  If 
%  they have entered their own vectors,
%  we keep it up.  If the vectors were
%  part of a "canned" presentation, we
%  will close it.  The windows are closed
%  in the __?__ program.

if defaults==1000
	global KeepInput
	KeepInput=1;
elseif defaults~=1000
	global KeepInput
	KeepInput=0;
end

%----------------------------------------

if defaults==1000	%They've entered their
			%own number of vectors
			%and have gotten here
			%from the vnv.m program
	vnvfig=gcf;
	kids=get(vnvfig,'Children');
	stra=get(kids(2),'String');
	numvectors=str2num(stra);	
	close (vnvfig);
	Mag=ones(1,numvectors);
	Freq=ones(1,numvectors);
	Phase=zeros(1,numvectors);
	global Sample
	Sample=20;

end



%*****************************************************

%To find out how many vectors are necessary and
%to specify default values

if defaults==2

	numvectors=1;
	Mag(1)=1;
	Freq(1)=1;
	Phase(1)=90;

elseif defaults==3

	numvectors=1;
	Mag(1)=1;
	Freq(1)=1;
	Phase(1)=0;

elseif defaults==4

	numvectors=1;
	Mag(1)=1;
	Freq(1)=1;
	Phase(1)=130;

%-----------------------------------------------------------
%Here is the odd-harmonic section
elseif defaults==5 | defaults==6 | defaults==7 | defaults==8
	
	if defaults==5
		numvectors=2;		
	elseif defaults==6
		numvectors=3;
	elseif defaults==7
		numvectors=4;
	elseif defaults==8
		numvectors=12;
	end
	Mag=zeros(1,numvectors);
	Freq=zeros(1,numvectors);
	Phase=zeros(1,numvectors);
	for cf=1:numvectors
		Mag(cf)=1/((2*cf)-1);
		Freq(cf)=(2*cf)-1;

	end	%End of for loop assigning Mag and Freq

%------------------------------------------------------------

elseif defaults==9.03 | defaults==9.05 | defaults==9.08 | defaults==9.16

	numvectors=(defaults*100)-900;
	Mag=zeros(1,numvectors);
	Freq=zeros(1,numvectors);
	Phase=zeros(1,numvectors);
	Mag(1)=1;
	Freq(1)=0;
	Phase(1)=90;
	for cf=2:numvectors
		Mag(cf)=2;
		Phase(cf)=90;
		Freq(cf)=cf-1;
	end	

elseif defaults==10.03 | defaults==10.05 | defaults==10.08 | defaults==10.16

	numvectors=(defaults*100)-1000;
	Mag=zeros(1,numvectors);
	Freq=zeros(1,numvectors);
	Phase=zeros(1,numvectors);
	for cf=1:numvectors;
		Freq(cf)=cf;
		Mag(cf)=1/cf;
	end
	
end	%End of finding out defaults


%************************************************
% To define the Sampling Rates
%-----------------------------

% To set the Sample Rate
if defaults==2 | defaults==3 | defaults==4
	global Sample
	Sample=100;
elseif defaults==5
	global Sample
	Sample=20;
elseif defaults==6
	global Sample
	Sample=20;
elseif defaults==7
	global Sample
	Sample=12;
elseif defaults==8
	global Sample
	Sample= 6;
elseif defaults==9.03 | defaults==9.05 | defaults==9.08 | defaults==9.16
	global Sample
	Sample=14;
elseif defaults==10.03 | defaults==10.05 | defaults==10.08 | defaults==10.16
	global Sample;
	Sample=10;
end

%-------------------------------------------------------------------------------
% To define the title string in spot (1,1)

global TitleInfo
TitleInfo=zeros(4,3);
if defaults==1000 | (defaults>=2 & defaults<=4) | (defaults>=10 & defaults~=1000)
	
% This is for manual entry of vectors, the simple sins and coss, and the sawtoothes
% and the impulses
	TitleInfo(1,1)=numvectors;
elseif defaults>=5 & defaults<=8
% This is for the square wave approximations
	TitleInfo(1,1)=(2*numvectors)-1;
elseif defaults>=9 & defaults<10
% This is for the impulses
	TitleInfo(1,1)=numvectors-1;
end
%-------------------------------------------------------------------------------

%*************************************************

%To set up the screen
global ManInScreen

ManInScreen=figure ('MenuBar','none','Name','Phasor Values To Be Used',...
	'NumberTitle','off','Units','normalized',...
	'Position',[eps, .1, .75, .74],...
	'Color',[0 .4 .4]);
%***********************************************************************

LetsGraph=uimenu ('Label','Let''s &Graph');
P1=['global Periods,Periods=1;global TitleInfo,TitleInfo(2,1)=1;mnreader'];
P2=['global Periods,Periods=2;global TitleInfo,TitleInfo(2,1)=2;mnreader'];
P3=['global Periods,Periods=3;global TitleInfo,TitleInfo(2,1)=3;mnreader'];
P4=['global Periods,Periods=4;global TitleInfo,TitleInfo(2,1)=4;mnreader'];
	uimenu(LetsGraph,'Label','&1.  One Period','Callback',P1);
	uimenu(LetsGraph,'Label','&2.  Two Periods','Callback',P2);
	uimenu(LetsGraph,'Label','&3.  Three Periods','Callback',P3);
	uimenu(LetsGraph,'Label','&4.  Four Periods','Callback',P4);

Alter=uimenu('Label','&Drawing Style');

VF=['global Sample,Sample=8;'];
F=['global Sample,Sample=12;'];
A=['global Sample,Sample=20;'];
S=['global Sample,Sample=40;'];
VS=['global Sample,Sample=100'];
	uimenu(Alter,'Label','V&ery Fast','Callback',VF);
	uimenu(Alter,'Label','&Fast','Callback',F);
	uimenu(Alter,'Label','&Average','Callback',A);
	uimenu(Alter,'Label','&Smooth','Callback',S);
	uimenu(Alter,'Label','Very Sm&ooth','Callback',VS);


PhaseIt=uimenu('Label','&Phase Shift','CallBack','pslide');

Windowing=uimenu('Label','&Windowing');
	uimenu(Windowing,'Label','&Fejer Window','CallBack','window(1)');
	uimenu(Windowing,'Label','&Hamming Window','CallBack','window(2)');

global LablHnd
LablHnd=uimenu('Label','&Labels are On','CallBack','labeler(1)');
	TitleInfo(1,3)=1;


%****************************************************************************



%The captions will be frames, which do nothing

frame=uicontrol ('Style','frame','Units','normalized',...
	'Position',[.01,.01,.98,.98]);


%-----------------------------------------------

%To set up the screen with the text boxes


VC=['Phasor  ',13,'Number'];
VectCaption=uicontrol('Style','text','Units','normalized',...
	'Position',[.02,.87,.12,.07],'ForeGroundColor','k',...
	'HorizontalAlignment','left','String',VC);
MC=['Magnitude',13,'Values'];
MagCaption=uicontrol('Style','text','Units','normalized',...
	'Position',[.17,.87,.12,.07],'ForeGroundColor','k',...
	'String',MC);
FC=['Frequency',13,'Values'];
FreqCaption=uicontrol('Style','text','Units','normalized',...
	'Position',[.47,.87,.12,.07],'ForeGroundColor','k',...
	'String',FC);
PC=['Phase',13,'Values'];
PhaseCaption=uicontrol('Style','text','Units','normalized',...
	'Position',[.765,.87,.13,.07],'ForeGroundColor','k',...
	'String',PC);


%**********************************************

%This part sets up the rows of
%Mags, Freqs, and Phases

global MagInfo
global FreqInfo
global PhaseInfo

for row=1:numvectors

	VectCapt(row)=uicontrol('Style','text','Units','normalized',...
		'Position',[.02, 1-(.14+(row*.05)),.05,.04],...
		'ForeGroundColor','k','String',row);
	MagInfo(row)=uicontrol('Style','edit','String',rats (Mag(row)),...
		'Units','normalized','Position',[.18, 1-(.14+(row*.05)),.1,.04],...
		'BackGroundColor','w','ForeGroundColor','k' );
	FreqInfo(row)=uicontrol('Style','edit','String',rats (Freq(row)),...
		'Units','normalized','Position',[.48, 1-(.14+(row*.05)),.1,.04],...
		'BackGroundColor','w','ForeGroundColor','k' );
	PhaseInfo(row)=uicontrol('Style','edit','String',Phase(row),...
		'Units','normalized','Position',[.8, 1-(.14+(row*.05)),.05,.04],...
		'BackGroundColor','w','ForeGroundColor','k' );
	

end
%--------------------------------------------------------

                                                                                                                                                                                                                                                                                                                                                                                                           HpfsDemo/mc.m                                                                                       0100666 0001512 0000145 00000004202 06422467531 0013736 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function outcome=mc (inpt)
%This function takes in [Mag, Freq, Phase;...]
%and calls reader, then graphs the result
%of reader with grapher

global numvectors
global ManInScreen
global KeepInput

if KeepInput==0
	if ManInScreen~=0
		close(ManInScreen)
	end
end


intermed=reader4 (inpt);

number=int2str(numvectors);
WinCapt=['Your Animation of ',number,' Phasors'];
AnimFig=figure ('MenuBar','none','NumberTitle','off',...
	'Units','normalized','Position',[.02, .02, .96, .85],...
	'Name',WinCapt,'UserData',['graph'],...
	'Color','k');

% If the labels are on, do the following
global TitleInfo
%------------------------------------------------------------
%------------------------------------------------------------
if TitleInfo(1,3)==1
%------------------------------------------------------------
HarmLabel=[int2str(TitleInfo(1,1)),' Harmonics   '];
PrdLabel=[int2str(TitleInfo(2,1)),' Periods'];
NewCapt=[number,' Phasors:     ',HarmLabel,PrdLabel];
set(AnimFig,'Name',NewCapt)

if TitleInfo(3,2)~=0
	PropLabel=[int2str(TitleInfo(3,2)),' degrees Prop. to Freq.'];
	Ptext=uicontrol('Style','text','Units','normalized',...
		'Position',[.6 .88 .3 .05],'String',PropLabel,...
		'BackgroundColor','k','ForegroundColor','b');
end

if TitleInfo(3,1)~=0
	ConsLabel=[int2str(TitleInfo(3,1)),' degrees Constant'];
	Ctext=uicontrol('Style','text','Units','normalized',...
		'Position',[.6 .94 .3 .05],'String',ConsLabel,...
		'BackgroundColor','k','ForegroundColor','b');
end

if TitleInfo(4,1)==1
	Fwin=['Fejer Windowing'];
	Ftext=uicontrol('Style','text','Units','normalized',...
		'Position',[.1 .94 .3 .05],'String','Fejer Window',...
		'BackgroundColor','k','ForegroundColor','b');
end

if TitleInfo(4,2)==1
	Owin=['Other Windowing'];
	Owin=uicontrol('Style','text','Units','normalized',...
		'Position',[.1 .88 .3 .05],'String','Hamming Window',...
		'BackgroundColor','k','ForegroundColor','b');
end

% end of assignments
%------------------------------------------------------------
end % of if Label are on loop
%------------------------------------------------------------
%------------------------------------------------------------

grapher6(intermed);

outcome=111;
                                                                                                                                                                                                                                                                                                                                                                                              HpfsDemo/mnreader.m                                                                                 0100666 0001512 0000145 00000001044 06422467531 0015135 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function mnreader
%This reads the info from the maninp
%screen and puts into the proper
%format, then passes it as an array
%to the mc program

global numvectors
global MagInfo FreqInfo PhaseInfo row
Mag=zeros(numvectors,1);
Freq=zeros(numvectors,1);
Phase=zeros(numvectors,1);


for i=1:numvectors

	str=get(MagInfo(i),'String');
	Mag(i,1)=str2num(str);
	str=get(FreqInfo(i),'String');
	Freq(i,1)=str2num(str);
	str=get(PhaseInfo(i),'String');
	Phase(i,1)=str2num(str);
end

matrix=zeros(numvectors,3);
matrix=[Mag, Freq, Phase];

mc(matrix);




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            HpfsDemo/pread.m                                                                                    0100666 0001512 0000145 00000003417 06422467532 0014442 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function nothing=pread(choice)
% This function reads data
% off the phase slider and does the following:
% 0   updates the display from slider
% .5  updates the display from text
% 1   gives a constant phase value
% 2   gives a proportional phase delay
% 3   applies the changes

global Psbox
global Pinfoval
global PropPha
global ConstPha


%---------------------------------

% This part updates the screen info

if choice==0
	curval=round(get(Psbox,'Value'));
	set(Pinfoval,'String',num2str(curval))
elseif choice==.5
	curval=str2num(get(Pinfoval,'String'));
	set(Psbox,'Value',curval);
end
%-------------------------------------------------

%  This part does the radio boxes
if choice==1
	set(PropPha,'Value',0)
	Prfl=0;
elseif choice==2
	set(ConstPha,'Value',0)
	Prfl=1;
end
%--------------------------------------------------

%  This part does the apply
if choice==3
	delay=round(get(Psbox,'Value'));
	PropOnOff=get(PropPha,'Value');
	if get(ConstPha,'Value')==0 & PropOnOff==0
		PropOnOff=1;
	end


%
%This function adds degrees to
%each value in the Phase coloumn

global numvectors PhaseInfo FreqInfo

for i=1:numvectors;
	str=get(PhaseInfo(i),'String');
	Phase(i)=str2num(str);
	frq=get(FreqInfo(i),'String');
	Freq(i)=str2num(frq);
	if PropOnOff==0
		Nphase(i)=Phase(i)+delay;
	elseif PropOnOff==1
		propdelay=delay*Freq(i);
		Nphase(i)=Phase(i)+propdelay;
	end
	set (PhaseInfo(i),'String',Nphase(i))
	
end % of numvectors loop

close(gcf)
%----------------------------------------------------
% To add the changes to what's in TitleInfo matrix
global TitleInfo
if PropOnOff==0  % a constant delay
	TitleInfo(3,1)=TitleInfo(3,1)+delay;
elseif PropOnOff==1 % a proportional delay
	TitleInfo(3,2)=TitleInfo(3,2)+delay;
end
%----------------------------------------------------

end %of choice 3
	                                                                                                                                                                                                                                                 HpfsDemo/pslide.m                                                                                   0100666 0001512 0000145 00000003175 06422467532 0014630 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function pslide
% This function sets up the phase slider
% to create a delay, which can be made 
% proportional to the frequency or
% simple by an added constant

global Psbox Pinfoval PropPha ConstPha

Pfig=figure('Name','Phase Shift','NumberTitle','off',...
	'MenuBar','none','Units','normalized',...
	'Position',[.05 .50 .45 .28],'Resize','off');



Psbox=uicontrol('Style','slider','units','normalized',...
	'Position',[.05 .6 .9 .2],'Min',-180,'Max',180,...
	'Value',0,'CallBack','pread(0)' );

Ptext1=uicontrol('style','Text','units','normalized',...
	'Position',[.05 .8 .1 .15],...
	'String','-180','BackGroundColor','k',...
	'ForeGroundColor','c');
Ptext2=uicontrol('style','Text','units','normalized',...
	'Position',[.85 .8 .1 .15],...
	'String','+180','BackGroundColor','k',...
	'ForeGroundColor','c');
Ptext3=uicontrol('style','Text','units','normalized',...
	'Position',[.45 .8 .1 .15],...
	'String','0','BackGroundColor','k',...
	'ForeGroundColor','c');


Pinfoval=uicontrol('Style','Edit','units','normalized',...
	'Position',[.8 .35 .1 .12],...
	'String',num2str(get(Psbox,'Value')),...
	'ForeGroundColor','w',...
	'CallBack','pread(.5)' );

PropPha=uicontrol('Style','radio','units','normalized',...
	'Position',[.05 .32 .57 .18],...
	'String','Proportional to Frequency',...
	'Value',1,'CallBack','pread(2)');

ConstPha=uicontrol('Style','radio','units','normalized',...
	'Position',[.05 .05 .57 .18],...
	'String','Constant Phase',...
	'Value',0,'CallBack','pread(1)');
ApString=['Click to apply.'];
Apply=uicontrol('Style','pushbutton','units','normalized',...
	'Position',[.72 .05 .25 .25],...
	'String',ApString,'CallBack','pread(3)');



                                                                                                                                                                                                                                                                                                                                                                                                   HpfsDemo/reader4.m                                                                                  0100666 0001512 0000145 00000003101 06422467532 0014663 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function woah=reader4 (s)

%This is a function returning info on the arguments
%Format is ([Mag1 Freq1 Phase1;Mag2 Freq2 Phase2,...])

if nargin==0
	disp 'Hey, give me something to work with!'
	end

dmns=[size(s)];

if dmns(2)~=3	%If don't have three attributes for vectors
	disp 'enter Magnitude, Freq, Phase Shift'
	end

numvectors=dmns(1);	%The number of vectors inputted
%--------------------------
woah=zeros(7,numvectors);	%Initializes the matrix
MagScale=0;
%--------------------------

%This part finds the minimum magn and freq
%as well as other info.
	MinMag=min(s(1:numvectors,1));
	MinFreq=min(s(1:numvectors,2));
	MaxMag=max(s(1:numvectors,1));
	MaxFreq=max(s(1:numvectors,2));

%-----------------------------------------------------

%This part puts everything in order and
%assigns it to the array woah


	%This puts the magnitudes and frequencies into woah
	%Couldn't do it by using elegant notation as above

	for loop=1:numvectors;
		woah(1,loop)=s(loop,1);
			MagScale=MagScale+abs(s(loop,1));
		woah(2,loop)=s(loop,2);
		woah(7,loop)=s(loop,3);

		%The 6th row will be the period array,
		%simply 1/frequency
		%Need to get rid of infinite periods caused
		%by a frequency of zero
		
		if s(loop,2)==0
			woah(6,loop)=1;
		else
			woah(6,loop)=1/(s(loop,2));
		end

	end

%This part finds the Resutling Frequency,
%which now will be the lc integer multiple
%of all the frequencies.
	ResultFreq=slcm2(woah(6,:));%This is the number of circles the
				   %for loop in the graphing function
				   %needs to do.


woah (3,1)=numvectors;
woah (4,1)=MagScale;
woah (5,1)=ResultFreq;


	                                                                                                                                                                                                                                                                                                                                                                                                                                                               HpfsDemo/slcm2.m                                                                                    0100666 0001512 0000145 00000001317 06422467532 0014364 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function result=slcm2 (ArrayInQstn)
%Least Commom Multiple (LCM) of an row of numbers.  
%Input is merely the row of numbers, output the LCM

result=0;
NMax=max(abs(ArrayInQstn));
numelements=size(ArrayInQstn,2);
sloop=1;

%If we're given a zero, it should not
%affect the value of the least common
%multiple.  Therefore, we will
%turn any zeros into ones

for zloop=1:numelements
	if ArrayInQstn(1,zloop)==0
		ArrayInQstn(1,zloop)=1;
	end
end
%*********************************************

for loop=1:numelements
	
	OMax=NMax; %Starts off each cycle ready to
		 %double the new NMax
	while srem2([NMax,ArrayInQstn(1,loop)])~=0
		sloop=sloop+1;
		NMax=sloop*OMax;
		end	%End of while loop
	end
end
result=NMax;




	

                                                                                                                                                                                                                                                                                                                 HpfsDemo/srem2.m                                                                                    0100666 0001512 0000145 00000000606 06422467533 0014375 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function [rslt]=srem2 (inpt)
%This function computes the remainder
%It will allow for decimals.

%Check to make sure second number isn't a zero
if inpt(1,2)==0
	disp ('Zero in the denominator!!! ')
break
end


%---------------------------------


answer=inpt(1,1)/inpt(1,2);
if answer==round (answer) %There is no remainder
	rslt=0;
else
   rslt=inpt(1,1)-( fix(answer)*inpt(1,2) );

end
 
                                                                                                                          HpfsDemo/vnv.m                                                                                      0100666 0001512 0000145 00000001145 06422467533 0014155 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        
%-------------------------------------------------
%If they choose to enter in their own values
%we need to find out how many vectors they want



NumFig=figure('MenuBar','none',...
	'Name','How many vectors would you like to enter?',...
	'NumberTitle','off','Units','normalized',...
	'Position',[.01, .8, .4, .08]);

NumBox=uicontrol('Style','edit','Units','normalized',...
	'Position',[.01, .06, .2, .81]);


ClickString=['Click here when ready'];
NumButton=uicontrol('Style','pushbutton','Units','normalized',...
	'Position',[.23, .03, .98, .86],...
	'String',ClickString,...
	'CallBack','maninp(1000)' );



                                                                                                                                                                                                                                                                                                                                                                                                                           HpfsDemo/window.m                                                                                   0100666 0001512 0000145 00000003156 06422467533 0014657 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function window(type)

% Type    What it does
%  1      Fejer Window
%  2      Hamming Window

% To get the frequencies and magnitudes

global FreqInfo MagInfo
global numvectors
global TitleInfo
for i=1:numvectors
	Freq(i)=str2num( get(FreqInfo(i),'String') );
	Mag(i)=str2num( get(MagInfo(i),'String') );
end

% To find N
% If (number of harmonics)=(2*numvectors)-1,
% then they probably are using a square wave approximation
% where N is actually the last unused even harmonic.
% For those calculations, we will let N=N+1
if TitleInfo(1,1)==(2*numvectors)-1
	N=max(Freq)+1;
else
	N=max(Freq);
end

%--------------------------------------------------------------
%--------------------------------------------------------------
if type==1
%--------------------------------------------------------------
% Fejer Windowing Function
% (N-k)/N
% N is the highest frequency
% k is the frequency of that term
	for i=1:numvectors
		weight=(N-Freq(i))/N;
		set( MagInfo(i),'String',rats( (weight*Mag(i)) ));
	end

TitleInfo(4,1)=1;
end % of type 1
%--------------------------------------------------------------

%--------------------------------------------------------------
%--------------------------------------------------------------
if type==2
%--------------------------------------------------------------
% Hamming Windowing Function
% (0.54 + 0.46cos(pi*k/N)
% N is the highest frequency
% k is the frequency of that term

	for i=1:numvectors
		weight=0.54+0.46*cos(pi*Freq(i)/N);
		set( MagInfo(i),'String',num2str( (weight*Mag(i)) ));
	end

TitleInfo(4,2)=1;
end % of type 2
%--------------------------------------------------------------
	                                                                                                                                                                                                                                                                                                                                                                                                                  HpfsDemo/                                                                                           0040755 0001512 0000145 00000000000 06422472755 0013166 5                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        HpfsDemo/arrange.m                                                                                  0100666 0001512 0000145 00000003037 06422467530 0014762 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function arrange(arg)

Graphs=findobj('UserData',['graph']);
%If there are no graphs, do nothing
if Graphs==[]
	return
end

NumGraphs=size(Graphs,1);
%-------------------------------------------------
%	Key
%
%10	Arrange the graphs
%20	Minimize the Graphs , Can't do this yet
%30	Close the Graphs





%**************************************************
if arg==10
%**************************************************

%This function arranges the graphs
%neatly on the screen


%To see if numgraphs is a perfect square
%If so, then it's easy
%If not, it will get messy...

if sqrt(NumGraphs)==round(sqrt(NumGraphs))
	Grws=sqrt(NumGraphs);
	Gclms=Grws;

else
	closest=NumGraphs;
	while sqrt(closest)~=round(sqrt(closest))
			closest=closest-1;
	end
	
Grws=sqrt(closest);
Gclms=Grws;
	while Grws*Gclms<NumGraphs
		Gclms=Gclms+1;
	end

end

%***************************************
%To compute the size of each figure

width=1/Gclms;
height=.86/Grws;
%---------------------------------------
%To place each graph on the screen
%The Grws:-1:1 helps to place the graphs in
%the order they were created.
i=1;
for r=Grws:-1:1
	BottomSpace(r)=(r-1)*height;

	for c=1:Gclms
		LeftSpace(c)=(c-1)*width;
		
		set(Graphs(i),'Units','normalized',...
			'Position',[ LeftSpace(c), BottomSpace(r)+.02,...
			width, height]);
		i=i+1;
		if i>NumGraphs
			return %It's over!
		end

	end
end
%***************************************
%***************************************

elseif arg==30
	delete (Graphs)
	return
end	%The end of all the elseifs...
	%Should be the last line of code


                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 HpfsDemo/demo.m                                                                                     0100666 0001512 0000145 00000011153 06422467530 0014265 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function stwin(speed)
clear global % Need to keep the speed 
		% variable for later

%Set up window
close all
home

%***************************************
StartTime=cputime;

%****************************

Title=['The Harmonic Phasor Demonstration'];

%StartWindow=figure ('Units','normalized', 'Position',[eps,1-eps,1-eps, .001],...
StartWindow=figure ('Units','normalized', 'Position',[eps,.9,1-eps, .01],...
	'NumberTitle','off','Name',Title,'MenuBar','none',...
	'Resize','on');

%***************************************************
%The manual entry window

OwnValues=uimenu('Label','Own &Values','CallBack','vnv');

%---------------------------------------
%Contents of the Intro Samples menu

IntroMenu=uimenu('Label','&Cosines');
	uimenu (IntroMenu,'Label','&cos (x)','CallBack','maninp(2)');
	uimenu (IntroMenu,'Label','&sin (x)','CallBack','maninp(3)');
	uimenu (IntroMenu,'Label','cos (x + 40 degrees)',...
		'CallBack','maninp(4)');


%-----------------------------------------
%Contents of Other Waveforms Menu

OtherMenu=uimenu('Label','&Other Waveforms');

	OddHarm=uimenu(OtherMenu,'Label','&Square Wave');
		uimenu (OddHarm,'Label','&3 Harmonics:  sin(x) + (1/3)sin(3x)','Callback','maninp(5)');
		uimenu (OddHarm,'Label','&5 Harmonics:    "   +(1/5)sin(5x)','CallBack','maninp(6)');
		uimenu (OddHarm,'Label','&7 Harmonics:    "   +(1/7)sin(7x)','CallBack','maninp(7)');
		uimenu (OddHarm,'Label','&23 Harmonics:  "  ...  +(1/23)sin(23)','CallBack','maninp(8)');

	Impulse=uimenu (OtherMenu,'Label','&Impulse Train');
		uimenu (Impulse,'Label','&1 Harmonics','CallBack','maninp(9.03)');
		uimenu (Impulse,'Label','&4 Harmonics','CallBack','maninp(9.05)');
		uimenu (Impulse,'Label','&7 Harmonics','CallBack','maninp(9.08)');
		uimenu (Impulse,'Label','&15 Harmonics','CallBack','maninp(9.16)');

	Saw=uimenu (OtherMenu,'Label','Sa&wtooth');
		uimenu(Saw,'Label','&3 Harmonics','CallBack','maninp(10.03)');
		uimenu(Saw,'Label','&5 Harmonics','CallBack','maninp(10.05)');
		uimenu(Saw,'Label','&8 Harmonics','CallBack','maninp(10.08)');
		uimenu(Saw,'Label','&16 Harmonics','CallBack','maninp(10.16)');


%-----------------------------------------
%Miscellaneous Items

Space=['                 '];
BlankSpace=uimenu('Label',Space);
CleaningUp=uimenu('Label','C&leaning Up');
	uimenu (CleaningUp,'Label','&Arrange','CallBack','arrange(10)');
	uimenu (CleaningUp,'Label','&Close all','Separator','on','CallBack','arrange(30)');
About=uimenu('Label','&About','Callback','about','Interruptible','yes');
Exit=uimenu('Label','Exit','Position',[0],'CallBack','close all');
%-------------------

%***************************************

if nargin == 1
	global SpeedFactor
	SpeedFactor=speed;

else	% Then go on with the test

%***************************************
testfig=figure ('Units','normalized', 'Position',[.1, .15,.8, .75],...
	'NumberTitle','off','Name','Speed Calibration','MenuBar','none',...
	'Resize','off');
pause(1)
axis ([-5 185 -.8 1.2])
axis off
Please=['Please wait while the program speed is calibrated...'];
title(Please)
Wait=['In the meantime, enjoy this preview...'];
text('Units','data','Position',[40 0],'String',Wait)

hold on
incr=2;
numvalues=180/incr +1;
deg=(2*pi)/360;
points=zeros(2,numvalues);
xval=zeros(1,numvalues);

for t=1:5	%5 vectors

yold=0;
xold=0;
cntr=0;
line([0 0],[0 .8],'Color','b','EraseMode','none')
line([0 180],[.8 .8],'Color','b','EraseMode','none')
line([180 180],[.8 0],'Color','b','EraseMode','none')
	for x=0:incr:180;
		cntr=cntr+1;
		nvalue=[(1/(2*t-1)) * sin((2*t-1)*deg*x)];
		points(t,cntr)=nvalue;
		%------------------------
		% To draw the points		
		yval(cntr)=sum(points(:,cntr));		
		PrevLine(t,cntr)=line([xold, x],[yold, yval(cntr)],'EraseMode','xor'...
			);
		yold=yval(cntr);
		xold=x;
		drawnow


	end
	pause(1)
	%if t~=0
	if t>1

		delete(PrevLine(t-1,:))
	end
	set(PrevLine(t,:),'Color',[.5 .5 .5])



end
%----------------------------
TimeElapsed=cputime-StartTime
%----------------------------	
pause(3)
title('') % This is to clear the axis title
cla
Where=['You may now use the demo by making a selection from above.'];
text('Units','data','Position',[10 .5],'String',Where)
pause (4)
delete (testfig)
%***************************************
MyComputer=22;
TheirsVsMine=MyComputer/TimeElapsed; 
SpeedFactor=(round(10*TheirsVsMine))/10
global SpeedFactor
% The 10 is because I wanted 1 decimal of
% accuracy after I round

%**********************************************

end	% end of the speedfactor determination
%**********************************************

clear	% to clear the variables that we didn't
	% clear in the clear global at the 
	% beginning.  Done this way so that the
	% variable speed was retained
-----------
%Miscellaneous Items

Space=['                 '];
BlankSpace=uimenu('Label',Space);
CleaningUp=uimenu('Label','C&leaning Up');
	uimenu (CleaningUp,'Label','&Arrange','CallBack','arrange(10)');
	uimenu (CleaningUp,'Label','&Close all','Separator','on','CallBack','arrange(30)');
About=uimenu('Label','&About','Callback','about','Interruptible','yes');
Exit=uimenu('Label','Exit','Position',[0]HpfsDemo/grapher6.m                                                                                 0100666 0001512 0000145 00000010165 06422467531 0015062 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function yeah=grapher6 (woah)
%This function takes in the info from reader4
%and graphs it into the rotating and linear
%animated displays.


%Definitions and variable clearing follow

DEG=2*pi/360;

%Information from reader function

numvectors=woah (3,1);
MagArray(1:numvectors)=woah(1,1:numvectors);
FreqArray(1:numvectors)=woah(2,1:numvectors);
PeriodArray(1:numvectors)=woah(6,1:numvectors);
PhaseArray(1:numvectors)=woah(7,1:numvectors);
LCMPeriod=woah(5,1);
MagScale=woah(4,1);

%*******************************************
%First set up the top-left axis

tl=subplot (1,2,1);

	%Now we set up the axis
	set(tl,'Units','normalized','Position',[0 .1 .47 .85])

	axis([-MagScale-.2 MagScale+.2...
		-MagScale-.2 MagScale+.2])
	axis square	
	axis off
	% To add the zero lines
	line([-.1*MagScale .1*MagScale],[0 0],...
		'Color',[.5 .5 .5],'EraseMode','none');
	line([0 0],[-.07*MagScale .07*MagScale],...
		'Color',[.5 .5 .5],'EraseMode','none');
%Now the top-right axis

tr=subplot(1,2,2);
global Periods;	
	set(tr,'Units','normalized','Position',[.5 .1 .47 .85])
	axis ([0 (360*(LCMPeriod)*Periods)+30 ...
 		-MagScale-.2 MagScale+.2])
	axis square
	axis off
	% To add the zero line
	line([0 (360*(LCMPeriod)*Periods)+30],[0 0],...
		'Color',[.5 .5 .5],'EraseMode','none');

%*********************************************************

%This part will do the drawing

%-----------------------------------------------------------

%xvold and yvold are to hold the old trace points,
%so that we may connect the dots to the new
%trace points.  Here we calculate the starting point,
%avoiding an if statement in the loop.
%The if statement would be needed to prevent drawing
%a line from the point 0,0 to the first end point of
%the sum of the vectors; it would check to make sure
%that xvold or yvold ~=0
xvold=0;
yvold=0;
xold=0;
yold=0;

%*******************************
subplot(tl)
for iloop=1:numvectors

		[xnew,ynew]=pol2cart( ( DEG*PhaseArray(iloop) ), MagArray(iloop));

		%To plot the lines and alternate colors
		if rem(iloop,2)==1
			rothandle(1,iloop)=line([xold,xold+xnew],...
			[yold,yold+ynew],'EraseMode','xor','Color','r');
		else
			rothandle(1,iloop)=line([xold,xold+xnew],...
			[yold,yold+ynew],'EraseMode','xor','Color','g');
		end
		drawnow;
		pause (1);
		xold=xold+xnew;
		yold=yold+ynew;
	end %We've now drawn each vector once

pause (2);
xvold=xvold+xold;
yvold=yvold+yold;
delete(rothandle(1,1:numvectors));
%**********************************8
%**********************************

%The main loop.
%Now we catch each vector at a rate of 360/Sample times
%A total of 'Periods' periods are performed

global Sample
global SpeedFactor
AdjustedSample=Sample*SpeedFactor;
SRate=360/AdjustedSample;
for dloop=0:(SRate/max(FreqArray)):(360*LCMPeriod)*Periods


%Need to compute once for each frequency

%xold and yold are the "relative origin" for each
%additional vector, the are continually changing
%but start at the origin.
xold=0;
yold=0;

subplot (tl)	%The rotating graph will be in the
		% top left

	for floop=1:numvectors

		[xnew,ynew]=pol2cart( (dloop*DEG*FreqArray(floop) ) + ( DEG*PhaseArray(floop) ),...
						MagArray(floop));

		%To plot the lines and alternate colors
		if rem(floop,2)==1
			rothandle(1,floop)=line([xold,xold+xnew],...
			[yold,yold+ynew],'EraseMode','xor','Color','r');
		else
			rothandle(1,floop)=line([xold,xold+xnew],...
			[yold,yold+ynew],'EraseMode','xor','Color','g');
		end

		xold=xold+xnew;
		yold=yold+ynew;
	end %We've now drawn each vector once


	%Now to connect the dots
	line ([xvold,xold],[yvold,yold],'EraseMode','none')


%****************************************************
%The next part will draw the cartesian version
%----------------------------------------------------

subplot(tr)

line ([(dloop-(SRate/max(FreqArray))),dloop],[yvold,yold],...
					'EraseMode','none')


%**********************************************

	xvold=xold;  %This is to store the last point plotted
	yvold=yold;  %so we can connect the dots


	%Now to delete the rotating graph
	subplot (tl)
	delete(rothandle(1:numvectors))

	%Now to draw everything
	drawnow


%**********************************************
%Now to go on to the next degree
end
                                                                                                                                                                                                                                                                                                                                                                                                           HpfsDemo/window.m                                                                                   0100666 0001512 0000145 00000003156 06422467533 0014657 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function window(type)

% Type    What it does
%  1      Fejer Window
%  2      Hamming Window

% To get the frequencies and magnitudes

global FreqInfo MagInfo
global numvectors
global TitleInfo
for i=1:numvectors
	Freq(i)=str2num( get(FreqInfo(i),'String') );
	Mag(i)=str2num( get(MagInfo(i),'String') );
end

% To find N
% If (number of harmonics)=(2*numvectors)-1,
% then they probably are using a square wave approximation
% where N is actually the last unused even harmonic.
% For those calculations, we will let N=N+1
if TitleInfo(1,1)==(2*numvectors)-1
	N=max(Freq)+1;
else
	N=max(Freq);
end

%--------------------------------------------------------------
%--------------------------------------------------------------
if type==1
%--------------------------------------------------------------
% Fejer Windowing Function
% (N-k)/N
% N is the highest frequency
% k is the frequency of that term
	for i=1:numvectors
		weight=(N-Freq(i))/N;
		set( MagInfo(i),'String',rats( (weight*Mag(i)) ));
	end

TitleInfo(4,1)=1;
end % of type 1
%--------------------------------------------------------------

%--------------------------------------------------------------
%--------------------------------------------------------------
if type==2
%--------------------------------------------------------------
% Hamming Windowing Function
% (0.54 + 0.46cos(pi*k/N)
% N is the highest frequency
% k is the frequency of that term

	for i=1:numvectors
		weight=0.54+0.46*cos(pi*Freq(i)/N);
		set( MagInfo(i),'String',num2str( (weight*Mag(i)) ));
	end

TitleInfo(4,2)=1;
end % of type 2
%--------------------------------------------------------------
	                                                                                                                                                                                                                                                                                                                                                                                                                  HpfsDemo/labeler.m                                                                                  0100666 0001512 0000145 00000000745 06422467531 0014755 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function labeler(choice)
% This adds labels to the animation window

%	Option	What it does	Where in TitleInfo
%	1	inteligent

global LablHnd
global TitleInfo

%-------------------------------------------------
% To check the status of labeling
if TitleInfo(1,3)==1		% it's on
	set(LablHnd,'Label','&Labels are off')
	TitleInfo(1,3)=0;
elseif TitleInfo(1,3)==0	% it's off
	set(LablHnd,'Label','&Labels are on')
	TitleInfo(1,3)=1;
end

%-------------------------------------------------
                           HpfsDemo/maninp.m                                                                                   0100666 0001512 0000145 00000017165 06422467531 0014635 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function output=maninp (defaults)

global numvectors;



%Function takes in defaults, which contains
%the default values for the type of graph
%requested.  It accepts modifications, and then
%passes the end matrix in proper form
%[Mag, Freq, Phase;...] to mc 

%Here is what each default value means:
%	1000	Own Inputs
%	2	cos x
%	3	cos x
%	4	sin x + cos x
%	5	odd harm to 1/3,3
%	6	odd harm to 1/5,5
%	7	odd harm to 1/7,7
%	8	odd harm to 1/23,23
%	9.?	Impulse train functions
%	10.?	Sawtooth functions

%***********************************************


%-----------------------------------------
%  To determine if we should keep
%  the maninput screen up.  If 
%  they have entered their own vectors,
%  we keep it up.  If the vectors were
%  part of a "canned" presentation, we
%  will close it.  The windows are closed
%  in the __?__ program.

if defaults==1000
	global KeepInput
	KeepInput=1;
elseif defaults~=1000
	global KeepInput
	KeepInput=0;
end

%----------------------------------------

if defaults==1000	%They've entered their
			%own number of vectors
			%and have gotten here
			%from the vnv.m program
	vnvfig=gcf;
	kids=get(vnvfig,'Children');
	stra=get(kids(2),'String');
	numvectors=str2num(stra);	
	close (vnvfig);
	Mag=ones(1,numvectors);
	Freq=ones(1,numvectors);
	Phase=zeros(1,numvectors);
	global Sample
	Sample=20;

end



%*****************************************************

%To find out how many vectors are necessary and
%to specify default values

if defaults==2

	numvectors=1;
	Mag(1)=1;
	Freq(1)=1;
	Phase(1)=90;

elseif defaults==3

	numvectors=1;
	Mag(1)=1;
	Freq(1)=1;
	Phase(1)=0;

elseif defaults==4

	numvectors=1;
	Mag(1)=1;
	Freq(1)=1;
	Phase(1)=130;

%-----------------------------------------------------------
%Here is the odd-harmonic section
elseif defaults==5 | defaults==6 | defaults==7 | defaults==8
	
	if defaults==5
		numvectors=2;		
	elseif defaults==6
		numvectors=3;
	elseif defaults==7
		numvectors=4;
	elseif defaults==8
		numvectors=12;
	end
	Mag=zeros(1,numvectors);
	Freq=zeros(1,numvectors);
	Phase=zeros(1,numvectors);
	for cf=1:numvectors
		Mag(cf)=1/((2*cf)-1);
		Freq(cf)=(2*cf)-1;

	end	%End of for loop assigning Mag and Freq

%------------------------------------------------------------

elseif defaults==9.03 | defaults==9.05 | defaults==9.08 | defaults==9.16

	numvectors=(defaults*100)-900;
	Mag=zeros(1,numvectors);
	Freq=zeros(1,numvectors);
	Phase=zeros(1,numvectors);
	Mag(1)=1;
	Freq(1)=0;
	Phase(1)=90;
	for cf=2:numvectors
		Mag(cf)=2;
		Phase(cf)=90;
		Freq(cf)=cf-1;
	end	

elseif defaults==10.03 | defaults==10.05 | defaults==10.08 | defaults==10.16

	numvectors=(defaults*100)-1000;
	Mag=zeros(1,numvectors);
	Freq=zeros(1,numvectors);
	Phase=zeros(1,numvectors);
	for cf=1:numvectors;
		Freq(cf)=cf;
		Mag(cf)=1/cf;
	end
	
end	%End of finding out defaults


%************************************************
% To define the Sampling Rates
%-----------------------------

% To set the Sample Rate
if defaults==2 | defaults==3 | defaults==4
	global Sample
	Sample=100;
elseif defaults==5
	global Sample
	Sample=20;
elseif defaults==6
	global Sample
	Sample=20;
elseif defaults==7
	global Sample
	Sample=12;
elseif defaults==8
	global Sample
	Sample= 6;
elseif defaults==9.03 | defaults==9.05 | defaults==9.08 | defaults==9.16
	global Sample
	Sample=14;
elseif defaults==10.03 | defaults==10.05 | defaults==10.08 | defaults==10.16
	global Sample;
	Sample=10;
end

%-------------------------------------------------------------------------------
% To define the title string in spot (1,1)

global TitleInfo
TitleInfo=zeros(4,3);
if defaults==1000 | (defaults>=2 & defaults<=4) | (defaults>=10 & defaults~=1000)
	
% This is for manual entry of vectors, the simple sins and coss, and the sawtoothes
% and the impulses
	TitleInfo(1,1)=numvectors;
elseif defaults>=5 & defaults<=8
% This is for the square wave approximations
	TitleInfo(1,1)=(2*numvectors)-1;
elseif defaults>=9 & defaults<10
% This is for the impulses
	TitleInfo(1,1)=numvectors-1;
end
%-------------------------------------------------------------------------------

%*************************************************

%To set up the screen
global ManInScreen

ManInScreen=figure ('MenuBar','none','Name','Phasor Values To Be Used',...
	'NumberTitle','off','Units','normalized',...
	'Position',[eps, .1, .75, .74],...
	'Color',[0 .4 .4]);
%***********************************************************************

LetsGraph=uimenu ('Label','Let''s &Graph');
P1=['global Periods,Periods=1;global TitleInfo,TitleInfo(2,1)=1;mnreader'];
P2=['global Periods,Periods=2;global TitleInfo,TitleInfo(2,1)=2;mnreader'];
P3=['global Periods,Periods=3;global TitleInfo,TitleInfo(2,1)=3;mnreader'];
P4=['global Periods,Periods=4;global TitleInfo,TitleInfo(2,1)=4;mnreader'];
	uimenu(LetsGraph,'Label','&1.  One Period','Callback',P1);
	uimenu(LetsGraph,'Label','&2.  Two Periods','Callback',P2);
	uimenu(LetsGraph,'Label','&3.  Three Periods','Callback',P3);
	uimenu(LetsGraph,'Label','&4.  Four Periods','Callback',P4);

Alter=uimenu('Label','&Drawing Style');

VF=['global Sample,Sample=8;'];
F=['global Sample,Sample=12;'];
A=['global Sample,Sample=20;'];
S=['global Sample,Sample=40;'];
VS=['global Sample,Sample=100'];
	uimenu(Alter,'Label','V&ery Fast','Callback',VF);
	uimenu(Alter,'Label','&Fast','Callback',F);
	uimenu(Alter,'Label','&Average','Callback',A);
	uimenu(Alter,'Label','&Smooth','Callback',S);
	uimenu(Alter,'Label','Very Sm&ooth','Callback',VS);


PhaseIt=uimenu('Label','&Phase Shift','CallBack','pslide');

Windowing=uimenu('Label','&Windowing');
	uimenu(Windowing,'Label','&Fejer Window','CallBack','window(1)');
	uimenu(Windowing,'Label','&Hamming Window','CallBack','window(2)');

global LablHnd
LablHnd=uimenu('Label','&Labels are On','CallBack','labeler(1)');
	TitleInfo(1,3)=1;


%****************************************************************************



%The captions will be frames, which do nothing

frame=uicontrol ('Style','frame','Units','normalized',...
	'Position',[.01,.01,.98,.98]);


%-----------------------------------------------

%To set up the screen with the text boxes


VC=['Phasor  ',13,'Number'];
VectCaption=uicontrol('Style','text','Units','normalized',...
	'Position',[.02,.87,.12,.07],'ForeGroundColor','k',...
	'HorizontalAlignment','left','String',VC);
MC=['Magnitude',13,'Values'];
MagCaption=uicontrol('Style','text','Units','normalized',...
	'Position',[.17,.87,.12,.07],'ForeGroundColor','k',...
	'String',MC);
FC=['Frequency',13,'Values'];
FreqCaption=uicontrol('Style','text','Units','normalized',...
	'Position',[.47,.87,.12,.07],'ForeGroundColor','k',...
	'String',FC);
PC=['Phase',13,'Values'];
PhaseCaption=uicontrol('Style','text','Units','normalized',...
	'Position',[.765,.87,.13,.07],'ForeGroundColor','k',...
	'String',PC);


%**********************************************

%This part sets up the rows of
%Mags, Freqs, and Phases

global MagInfo
global FreqInfo
global PhaseInfo

for row=1:numvectors

	VectCapt(row)=uicontrol('Style','text','Units','normalized',...
		'Position',[.02, 1-(.14+(row*.05)),.05,.04],...
		'ForeGroundColor','k','String',row);
	MagInfo(row)=uicontrol('Style','edit','String',rats (Mag(row)),...
		'Units','normalized','Position',[.18, 1-(.14+(row*.05)),.1,.04],...
		'BackGroundColor','w','ForeGroundColor','k' );
	FreqInfo(row)=uicontrol('Style','edit','String',rats (Freq(row)),...
		'Units','normalized','Position',[.48, 1-(.14+(row*.05)),.1,.04],...
		'BackGroundColor','w','ForeGroundColor','k' );
	PhaseInfo(row)=uicontrol('Style','edit','String',Phase(row),...
		'Units','normalized','Position',[.8, 1-(.14+(row*.05)),.05,.04],...
		'BackGroundColor','w','ForeGroundColor','k' );
	

end
%--------------------------------------------------------

                                                                                                                                                                                                                                                                                                                                                                                                           HpfsDemo/mc.m                                                                                       0100666 0001512 0000145 00000004202 06422467531 0013736 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function outcome=mc (inpt)
%This function takes in [Mag, Freq, Phase;...]
%and calls reader, then graphs the result
%of reader with grapher

global numvectors
global ManInScreen
global KeepInput

if KeepInput==0
	if ManInScreen~=0
		close(ManInScreen)
	end
end


intermed=reader4 (inpt);

number=int2str(numvectors);
WinCapt=['Your Animation of ',number,' Phasors'];
AnimFig=figure ('MenuBar','none','NumberTitle','off',...
	'Units','normalized','Position',[.02, .02, .96, .85],...
	'Name',WinCapt,'UserData',['graph'],...
	'Color','k');

% If the labels are on, do the following
global TitleInfo
%------------------------------------------------------------
%------------------------------------------------------------
if TitleInfo(1,3)==1
%------------------------------------------------------------
HarmLabel=[int2str(TitleInfo(1,1)),' Harmonics   '];
PrdLabel=[int2str(TitleInfo(2,1)),' Periods'];
NewCapt=[number,' Phasors:     ',HarmLabel,PrdLabel];
set(AnimFig,'Name',NewCapt)

if TitleInfo(3,2)~=0
	PropLabel=[int2str(TitleInfo(3,2)),' degrees Prop. to Freq.'];
	Ptext=uicontrol('Style','text','Units','normalized',...
		'Position',[.6 .88 .3 .05],'String',PropLabel,...
		'BackgroundColor','k','ForegroundColor','b');
end

if TitleInfo(3,1)~=0
	ConsLabel=[int2str(TitleInfo(3,1)),' degrees Constant'];
	Ctext=uicontrol('Style','text','Units','normalized',...
		'Position',[.6 .94 .3 .05],'String',ConsLabel,...
		'BackgroundColor','k','ForegroundColor','b');
end

if TitleInfo(4,1)==1
	Fwin=['Fejer Windowing'];
	Ftext=uicontrol('Style','text','Units','normalized',...
		'Position',[.1 .94 .3 .05],'String','Fejer Window',...
		'BackgroundColor','k','ForegroundColor','b');
end

if TitleInfo(4,2)==1
	Owin=['Other Windowing'];
	Owin=uicontrol('Style','text','Units','normalized',...
		'Position',[.1 .88 .3 .05],'String','Hamming Window',...
		'BackgroundColor','k','ForegroundColor','b');
end

% end of assignments
%------------------------------------------------------------
end % of if Label are on loop
%------------------------------------------------------------
%------------------------------------------------------------

grapher6(intermed);

outcome=111;
                                                                                                                                                                                                                                                                                                                                                                                              HpfsDemo/mnreader.m                                                                                 0100666 0001512 0000145 00000001044 06422467531 0015135 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function mnreader
%This reads the info from the maninp
%screen and puts into the proper
%format, then passes it as an array
%to the mc program

global numvectors
global MagInfo FreqInfo PhaseInfo row
Mag=zeros(numvectors,1);
Freq=zeros(numvectors,1);
Phase=zeros(numvectors,1);


for i=1:numvectors

	str=get(MagInfo(i),'String');
	Mag(i,1)=str2num(str);
	str=get(FreqInfo(i),'String');
	Freq(i,1)=str2num(str);
	str=get(PhaseInfo(i),'String');
	Phase(i,1)=str2num(str);
end

matrix=zeros(numvectors,3);
matrix=[Mag, Freq, Phase];

mc(matrix);




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            HpfsDemo/pread.m                                                                                    0100666 0001512 0000145 00000003417 06422467532 0014442 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function nothing=pread(choice)
% This function reads data
% off the phase slider and does the following:
% 0   updates the display from slider
% .5  updates the display from text
% 1   gives a constant phase value
% 2   gives a proportional phase delay
% 3   applies the changes

global Psbox
global Pinfoval
global PropPha
global ConstPha


%---------------------------------

% This part updates the screen info

if choice==0
	curval=round(get(Psbox,'Value'));
	set(Pinfoval,'String',num2str(curval))
elseif choice==.5
	curval=str2num(get(Pinfoval,'String'));
	set(Psbox,'Value',curval);
end
%-------------------------------------------------

%  This part does the radio boxes
if choice==1
	set(PropPha,'Value',0)
	Prfl=0;
elseif choice==2
	set(ConstPha,'Value',0)
	Prfl=1;
end
%--------------------------------------------------

%  This part does the apply
if choice==3
	delay=round(get(Psbox,'Value'));
	PropOnOff=get(PropPha,'Value');
	if get(ConstPha,'Value')==0 & PropOnOff==0
		PropOnOff=1;
	end


%
%This function adds degrees to
%each value in the Phase coloumn

global numvectors PhaseInfo FreqInfo

for i=1:numvectors;
	str=get(PhaseInfo(i),'String');
	Phase(i)=str2num(str);
	frq=get(FreqInfo(i),'String');
	Freq(i)=str2num(frq);
	if PropOnOff==0
		Nphase(i)=Phase(i)+delay;
	elseif PropOnOff==1
		propdelay=delay*Freq(i);
		Nphase(i)=Phase(i)+propdelay;
	end
	set (PhaseInfo(i),'String',Nphase(i))
	
end % of numvectors loop

close(gcf)
%----------------------------------------------------
% To add the changes to what's in TitleInfo matrix
global TitleInfo
if PropOnOff==0  % a constant delay
	TitleInfo(3,1)=TitleInfo(3,1)+delay;
elseif PropOnOff==1 % a proportional delay
	TitleInfo(3,2)=TitleInfo(3,2)+delay;
end
%----------------------------------------------------

end %of choice 3
	                                                                                                                                                                                                                                                 HpfsDemo/pslide.m                                                                                   0100666 0001512 0000145 00000003175 06422467532 0014630 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function pslide
% This function sets up the phase slider
% to create a delay, which can be made 
% proportional to the frequency or
% simple by an added constant

global Psbox Pinfoval PropPha ConstPha

Pfig=figure('Name','Phase Shift','NumberTitle','off',...
	'MenuBar','none','Units','normalized',...
	'Position',[.05 .50 .45 .28],'Resize','off');



Psbox=uicontrol('Style','slider','units','normalized',...
	'Position',[.05 .6 .9 .2],'Min',-180,'Max',180,...
	'Value',0,'CallBack','pread(0)' );

Ptext1=uicontrol('style','Text','units','normalized',...
	'Position',[.05 .8 .1 .15],...
	'String','-180','BackGroundColor','k',...
	'ForeGroundColor','c');
Ptext2=uicontrol('style','Text','units','normalized',...
	'Position',[.85 .8 .1 .15],...
	'String','+180','BackGroundColor','k',...
	'ForeGroundColor','c');
Ptext3=uicontrol('style','Text','units','normalized',...
	'Position',[.45 .8 .1 .15],...
	'String','0','BackGroundColor','k',...
	'ForeGroundColor','c');


Pinfoval=uicontrol('Style','Edit','units','normalized',...
	'Position',[.8 .35 .1 .12],...
	'String',num2str(get(Psbox,'Value')),...
	'ForeGroundColor','w',...
	'CallBack','pread(.5)' );

PropPha=uicontrol('Style','radio','units','normalized',...
	'Position',[.05 .32 .57 .18],...
	'String','Proportional to Frequency',...
	'Value',1,'CallBack','pread(2)');

ConstPha=uicontrol('Style','radio','units','normalized',...
	'Position',[.05 .05 .57 .18],...
	'String','Constant Phase',...
	'Value',0,'CallBack','pread(1)');
ApString=['Click to apply.'];
Apply=uicontrol('Style','pushbutton','units','normalized',...
	'Position',[.72 .05 .25 .25],...
	'String',ApString,'CallBack','pread(3)');



                                                                                                                                                                                                                                                                                                                                                                                                   HpfsDemo/reader4.m                                                                                  0100666 0001512 0000145 00000003101 06422467532 0014663 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function woah=reader4 (s)

%This is a function returning info on the arguments
%Format is ([Mag1 Freq1 Phase1;Mag2 Freq2 Phase2,...])

if nargin==0
	disp 'Hey, give me something to work with!'
	end

dmns=[size(s)];

if dmns(2)~=3	%If don't have three attributes for vectors
	disp 'enter Magnitude, Freq, Phase Shift'
	end

numvectors=dmns(1);	%The number of vectors inputted
%--------------------------
woah=zeros(7,numvectors);	%Initializes the matrix
MagScale=0;
%--------------------------

%This part finds the minimum magn and freq
%as well as other info.
	MinMag=min(s(1:numvectors,1));
	MinFreq=min(s(1:numvectors,2));
	MaxMag=max(s(1:numvectors,1));
	MaxFreq=max(s(1:numvectors,2));

%-----------------------------------------------------

%This part puts everything in order and
%assigns it to the array woah


	%This puts the magnitudes and frequencies into woah
	%Couldn't do it by using elegant notation as above

	for loop=1:numvectors;
		woah(1,loop)=s(loop,1);
			MagScale=MagScale+abs(s(loop,1));
		woah(2,loop)=s(loop,2);
		woah(7,loop)=s(loop,3);

		%The 6th row will be the period array,
		%simply 1/frequency
		%Need to get rid of infinite periods caused
		%by a frequency of zero
		
		if s(loop,2)==0
			woah(6,loop)=1;
		else
			woah(6,loop)=1/(s(loop,2));
		end

	end

%This part finds the Resutling Frequency,
%which now will be the lc integer multiple
%of all the frequencies.
	ResultFreq=slcm2(woah(6,:));%This is the number of circles the
				   %for loop in the graphing function
				   %needs to do.


woah (3,1)=numvectors;
woah (4,1)=MagScale;
woah (5,1)=ResultFreq;


	                                                                                                                                                                                                                                                                                                                                                                                                                                                               HpfsDemo/slcm2.m                                                                                    0100666 0001512 0000145 00000001317 06422467532 0014364 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function result=slcm2 (ArrayInQstn)
%Least Commom Multiple (LCM) of an row of numbers.  
%Input is merely the row of numbers, output the LCM

result=0;
NMax=max(abs(ArrayInQstn));
numelements=size(ArrayInQstn,2);
sloop=1;

%If we're given a zero, it should not
%affect the value of the least common
%multiple.  Therefore, we will
%turn any zeros into ones

for zloop=1:numelements
	if ArrayInQstn(1,zloop)==0
		ArrayInQstn(1,zloop)=1;
	end
end
%*********************************************

for loop=1:numelements
	
	OMax=NMax; %Starts off each cycle ready to
		 %double the new NMax
	while srem2([NMax,ArrayInQstn(1,loop)])~=0
		sloop=sloop+1;
		NMax=sloop*OMax;
		end	%End of while loop
	end
end
result=NMax;




	

                                                                                                                                                                                                                                                                                                                 HpfsDemo/srem2.m                                                                                    0100666 0001512 0000145 00000000606 06422467533 0014375 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        function [rslt]=srem2 (inpt)
%This function computes the remainder
%It will allow for decimals.

%Check to make sure second number isn't a zero
if inpt(1,2)==0
	disp ('Zero in the denominator!!! ')
break
end


%---------------------------------


answer=inpt(1,1)/inpt(1,2);
if answer==round (answer) %There is no remainder
	rslt=0;
else
   rslt=inpt(1,1)-( fix(answer)*inpt(1,2) );

end
 
                                                                                                                          HpfsDemo/vnv.m                                                                                      0100666 0001512 0000145 00000001145 06422467533 0014155 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        
%-------------------------------------------------
%If they choose to enter in their own values
%we need to find out how many vectors they want



NumFig=figure('MenuBar','none',...
	'Name','How many vectors would you like to enter?',...
	'NumberTitle','off','Units','normalized',...
	'Position',[.01, .8, .4, .08]);

NumBox=uicontrol('Style','edit','Units','normalized',...
	'Position',[.01, .06, .2, .81]);


ClickString=['Click here when ready'];
NumButton=uicontrol('Style','pushbutton','Units','normalized',...
	'Position',[.23, .03, .98, .86],...
	'String',ClickString,...
	'CallBack','maninp(1000)' );



                                                                                                                                                                                                                                                                                                                                                                                                                           HpfsDemo/about.m                                                                                    0100666 0001512 0000145 00000004553 06422472334 0014457 0                                                                                                    ustar 00nazar                           users                           0000243 0005337                                                                                                                                                                        % This is the About selection


AboutFig=figure('Units','Normalized','Position',[.4 .35 .5 .55],...
	'MenuBar','none',...
	'Name','About The Rotating Vector Demonstration',...
	'NumberTitle','off','Resize','on','UserData',['graph']);

TextFrame=uicontrol('Style','frame','Units','normalized',...
	'Position',[.03 .52 .94 .45]);

CloseIt=uicontrol('Style','pushbutton','Units','normalized',...
	'Position',[.5 .53 .43 .07],'String','Close this Window',...
	'Callback','close');

l1=['This program was developed by Nabeel B. Azar '];
l2=['in a project directed by Wilson J. Rugh, with the support '];
l3=['of the National Science Foundation and the Kenan Fund for '];
l4=['Undergraduate Education at The Johns Hopkins University.  '];
l5=['This program is based on ideas from the 1971 movie '];
l6=['"Harmonic Phasors II," produced by William H. Huggins '];
l7=['at The Johns Hopkins University.'];
CreditText=[l1,l2,l3,l4,l5,l6,l7];
Credits=uicontrol('Style','text','Units','normalized',...
	'Position',[.05 .63 .87 .33],'ForeGroundColor','k',...
	'HorizontalAlignment','left','String',CreditText);

%-------------------------------------------

subplot(2,1,2)
axis ([-1 181 0 1])
axis off
hold on
global SpeedFactor
incr=round(3/SpeedFactor);
if incr==0
	incr=.5;
end

numvalues=180/incr +1;
deg=(2*pi)/360;
points=zeros(2,numvalues);
xval=zeros(1,numvalues);
t=0;
for t=1:500		%  Up to 500 vectors
			%  if they wait long enough !!!


yold=0;
xold=0;
cntr=0;
line([0 0],[0 .8],'Color','b','EraseMode','none')
line([0 180],[.8 .8],'Color','b','EraseMode','none')
line([180 180],[.8 0],'Color','b','EraseMode','none')

	for x=0:incr:180;
		cntr=cntr+1;
		nvalue=[(1/(2*t-1)) * sin((2*t-1)*deg*x)];
		points(t,cntr)=nvalue;
		%------------------------
		% To draw the points		
		yval(cntr)=sum(points(:,cntr));		
		PrevLine(t,cntr)=line([xold, x],[yold, yval(cntr)],...
		'EraseMode','xor');
		yold=yval(cntr);
		xold=x;
		drawnow


	end
	%  We want to pause if fewer than 7
	% vectors.  If more, we want to hurry
	% up and watch it change to the square wave
	
	if t < 7
		pause(1)
	end

%-------------------------------
%  Is the figure window still there?
%  If not, it has been closed and
%  we don't need to continue execution
%
if gcf~=AboutFig
	break
end
%
%-------------------------------

	if t~=1
		delete(PrevLine(t-1,:))
	end

	set(PrevLine(t,:),'Color',[.5 .5 .5])



end
%----------------------------                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     