www.gusucode.com > signal 案例源码程序 matlab代码 > signal/ModifyMscohereDefaultPlotExample.m

    %% Modify |mscohere| Default Plot
% Generate two sinusoidal signals sampled for 1 second each at
% 1 kHz. Each sinusoid has a frequency of 250 Hz. One of the
% signals lags the other in phase by _π_/3 radians. Embed both
% signals in white Gaussian noise of unit variance. Reset the random number
% generator for reproducible results.

rng default
fs = 1000;
f = 250;
t = 0:1/fs:1-1/fs;
um = sin(2*pi*f*t)+rand(size(t));
un = sin(2*pi*f*t-pi/3)+rand(size(t));

%%
% Use |mscohere| to compute and plot the magnitude-squared coherence of the
% signals.

mscohere(um,un,[],[],[],fs)

%%
% Modify the title of the plot, the label of the _x_-axis, and the limits
% of the _y_-axis.

title('Magnitude-Squared Coherence')
xlabel('f (Hz)')
ylim([0 1.1])

%%
% Use |gca| to obtain a handle to the current axes. Change the locations of
% the tick marks. Remove the label of the _y_-axis.

ax = gca;
ax.XTick = 0:250:500;
ax.YTick = 0:0.25:1;
ax.YLabel.String = [];

%%
% Invoke the |Children| property of the handle to change the color and
% width of the plotted line.

ln = ax.Children;
ln.Color = [0.8 0 0];
ln.LineWidth = 1.5;

%%
% Alternatively, use |set| and |get| to modify the line properties.

set(get(gca,'Children'),'Color',[0 0.4 0],'LineStyle','--','LineWidth',1)