summaryrefslogtreecommitdiff
path: root/macros/mscohere.sci
blob: 357da588bcf86ce3f2aef374247a80d454e4f711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function [PXX, FREQ] = mscohere (X, Y, WINDOW, OVERLAP, NFFT, FS, RANGE)
//It estimate (mean square) coherence of signals x and y. 
//Calling Sequence
//[Pxx, freq] = mscohere (x, y)
//[Pxx, freq] = mscohere (x, y, window)
//[Pxx, freq] = mscohere (x, y, window, overlap)
//[Pxx, freq] = mscohere (x, y, window, overlap, Nfft)
//[Pxx, freq] = mscohere (x, y, window, overlap, Nfft, Fs)
//[Pxx, freq] = mscohere (x, y, window, overlap, Nfft, Fs, range)
//mscohere (...)
//Description
//This function estimate (mean square) coherence of signals x and y. 
//Examples
//[Pxx, freq] = mscohere(4,5)
//ans =
//PXX = 
//    Nan
//     1
//FREQ =
//     0
//     0.5
funcprot(0);
lhs = argn(1)
rhs = argn(2)
if (rhs < 2 | rhs > 7)
error("Wrong number of input arguments.")
end

select(rhs)
	
	case 2 then
		if(lhs==0)
		callOctave("mscohere",X,Y)
		elseif(lhs==2)
		[PXX, FREQ] = callOctave("mscohere",X,Y)
		else
		error("Wrong number of output arguments.")
		end

	case 3 then
		if(lhs==0)
		callOctave("mscohere",X,Y,WINDOW)
		elseif(lhs==2)
		[PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW)
		else
		error("Wrong number of output arguments.")
	       	end
	case 4 then
		if(lhs==0)
		callOctave("mscohere",X,Y,WINDOW,OVERLAP)
		elseif(lhs==2)
		[PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW,OVERLAP)
		else
		error("Wrong number of output arguments.")
	       	end
	case 5 then
		if(lhs==0)
		callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT)
		elseif(lhs==2)
		[PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT)
		else
		error("Wrong number of output arguments.")
	       	end
	case 6 then
		if(lhs==0)
		callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT,FS)
		elseif(lhs==2)
		[PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT,FS)
		else
		error("Wrong number of output arguments.")
	       	end
	case 7 then
		if(lhs==0)
		callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT,FS,RANGE,)
		elseif(lhs==2)
		[PXX, FREQ] = callOctave("mscohere",X,Y,WINDOW,OVERLAP,NFFT,FS,RANGE)
		else
		error("Wrong number of output arguments.")
	       	end
	end
endfunction