This function returns a two-dimension coherence representation between two time waves. The function corresponds to a sliding coherence function along the two signals. This produces a 2-D density plot. An amplitude contour plot can be overlaid.
ccoh(wave1, wave2, f, channel = c(1,1), wl = 512, ovlp = 0, plot = TRUE,
grid = TRUE, scale = TRUE, cont = FALSE,
collevels = seq(0, 1, 0.01), palette = reverse.heat.colors,
contlevels = seq(0, 1, 0.01), colcont = "black",
colbg="white", colgrid = "black",
colaxis = "black", collab="black",
xlab = "Time (s)", ylab = "Frequency (kHz)",
scalelab = "Coherence",
main = NULL,
scalefontlab = 1, scalecexlab =0.75, axisX = TRUE, axisY = TRUE,
flim = NULL, flimd = NULL,
...)
a first R object
a second R object
sampling frequency of wave
(in Hz). Does not need to be specified if embedded in wave
.
channel of the R objects, by default left channel (1) for each object.
window length for the analysis (even number of points, by default = 512).
overlap between two successive windows (in %).
logical, if TRUE
plots the continuous coherence function
(by default TRUE
).
logical, if TRUE
plots a y-axis grid
(by default TRUE
).
logical, if TRUE
plots a dB colour scale on the right
side of the plot (by default TRUE
).
logical, if TRUE
overplots contour lines on the plot
(by default FALSE
).
a set of levels which are used to partition the amplitude range of the coherence (should be between 0 and 1.
a color palette function to be used to assign colors in
the plot, see Details
.
a set of levels which are used to partition the amplitude range for contour overplot (in dB).
colour for cont
plotting.
background colour.
colour for grid
plotting.
color of the axes.
color of the labels.
label of the time axis.
label of the frequency axis.
label fo the amplitude scale.
label of the main title.
font of the amplitude scale label.
cex of the amplitude scale label.
logical, if TRUE
plots time X-axis (by default TRUE
).
logical, if TRUE
plots frequency Y-axis (by default TRUE
).
modifications of the frequency Y-axis limits.
dynamic modifications of the frequency Y-axis limits. New wl
and ovlp
arguments are applied to increase time/frequency resolution.
This function returns a list of three items:
a numeric vector corresponding to the time axis.
a numeric vector corresponding to the frequency axis.
a numeric matrix corresponding to the coherence.
Each column corresponds to a coherence function of length wl
.
Coherence is a frequency domain function computed to show the degree
of a relationship between two signals.
The value of the coherence function ranges between zero and one,
where a value of zero indicates there is no causal relationship between the signals.
A value of one indicates the existence of linear frequency response between the
two signals. This can be used, for instance, to compare the input and output
signals of a system.
Any colour palette can be used. In particular, it is possible to use other
palettes coming with seewave: temp.colors
, reverse.gray.colors.1
,
reverse.gray.colors.2
,
spectro.colors
, reverse.terrain.colors
,
reverse.topo.colors
, reverse.cm.colors
corresponding
to the reverse of terrain.colors
, topo.colors
,
cm.colors
.
Use locator
to identify points.
coh
, spectro
, spec.pgram
.
# NOT RUN {
wave1<-synth(d=1,f=4000,cf=500)
wave2<-synth(d=1,f=4000,cf=800)
ccoh(wave1,wave2,f=4000)
# }
Run the code above in your browser using DataLab