matlab使用xcorr函数求互相关函数时出现输入参数过多的报错,请问为什么?
```c
properties (Access = private)
Property % Description
Fs;
dt;
DF;
T;
N;
t;
wave1;%波形1
wave2;%波形2
type1;%信号1
type2;
F1;
A1;
F2;
A2;
end
methods (Access = private)
function results = drawsingal1(app,type1,A1,F1)
app.t = linspace(0,1,app.N);
if type1==0
app.wave1 = app.A1*sin(2*pi*app.F1*app.t/100);
end
if type1==1
app.wave1 = app.A1*square(2*pi*app.F1*app.t/100);
end
if type1==2
app.wave1=app.A1*sawtooth(2*pi*app.F1*app.t/100);
end
if type1==3
app.wave1=app.A1*0.2*randn(1,app.N);
end
xlim(app.UIAxes,[0,1]);
ylim(app.UIAxes,[-1,1]);
plot(app.UIAxes,app.t,app.wave1);
end
function results = drawSingal2(app,type2,A2,F2)
app.t = linspace(0,1,app.N);
if type2==0
app.wave2 = app.A2*sin(2*pi*app.F2*app.t/100);
end
if type2==1
app.wave2 = app.A2*square(2*pi*app.F2*app.t/100);
end
if type2==2
app.wave2=app.A2*sawtooth(2*pi*app.F2*app.t/100);
end
if type2==3
app.wave2=app.A2*0.2*randn(1,app.N);
end
xlim(app.UIAxes2,[0,1]);
ylim(app.UIAxes2,[-1,1]);
plot(app.UIAxes2,app.t,app.wave2);
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.Fs = 44100;
app.N = 44100;
app.A1 = 1;
app.A2=1;
app.F1 = 1000;
app.F2 = 1000;
app.type1=0;
app.type2=0;
end
% Value changed function: EditField
function EditFieldValueChanged(app, event)
value = app.EditField.Value;
app.Slider.Value = value;%把文本框的值赋给滑块
app.F1 = app.Slider.Value;
end
% Value changing function: Slider
function SliderValueChanging(app, event)
changingValue = event.Value;
app.EditField.Value = changingValue;%把滑块的值赋给文本框
end
% Value changed function: EditField_3
function EditField_3ValueChanged(app, event)
value = app.EditField_3.Value;
app.Slider_3.Value = value;%把文本框的值赋给滑块
app.A1 = app.Slider_3.Value;
end
% Value changing function: Slider_3
function Slider_3ValueChanging(app, event)
changingValue = event.Value;
app.EditField_3.Value = changingValue;%把滑块的值赋给文本框
app.A1 = changingValue;
end
% Selection changed function: ButtonGroup
function ButtonGroupSelectionChanged(app, event)
selectedButton = app.ButtonGroup.SelectedObject;
if selectedButton==app.Button
app.type1=0;
end
if selectedButton==app.Button_2
app.type1=1;
end
if selectedButton==app.Button_3
app.type1=2;
end
if selectedButton==app.Button_4
app.type1=3;
end
drawsingal1(app,app.type1,app.A1,app.F1);
end
% Value changed function: EditField_2
function EditField_2ValueChanged(app, event)
value = app.EditField_2.Value;
app.Slider.Value = value;%把文本框的值赋给滑块
app.F2 = app.Slider_2.Value;
end
% Value changing function: Slider_2
function Slider_2ValueChanging(app, event)
changingValue = event.Value;
app.EditField_2.Value = changingValue;%把滑块的值赋给文本框
end
% Value changed function: EditField_4
function EditField_4ValueChanged(app, event)
value = app.EditField_4.Value;
app.Slider_4.Value = value;%把文本框的值赋给滑块
app.A2 = app.Slider_4.Value;
end
% Value changing function: Slider_4
function Slider_4ValueChanging(app, event)
changingValue = event.Value;
app.EditField_4.Value = changingValue;%把滑块的值赋给文本框
app.A2 = changingValue;
end
% Selection changed function: ButtonGroup_2
function ButtonGroup_2SelectionChanged(app, event)
selectedButton = app.ButtonGroup_2.SelectedObject;
if selectedButton==app.Button_5
app.type2=0;
end
if selectedButton==app.Button_6
app.type2=1;
end
if selectedButton==app.Button_7
app.type2=2;
end
if selectedButton==app.Button_8
app.type2=3;
end
drawSingal2(app,app.type2,app.A2,app.F2);
end
% Button pushed function: Button_9
function Button_9Pushed(app, event)
drawsingal1(app,app.type1,app.A1,app.F1);
drawSingal2(app,app.type2,app.A2,app.F2);
T = 1;
r1=xcorr(app.wave1,app.wave2);
N1=length(r1);
x3=linspace(-T,T,N1);
plot(app.UIAxes3,x3,r1);
xlim([-T/2,T/2]);
ylim([-1,1]);
end
% Button pushed function: FFTButton
function FFTButtonPushed(app, event)
T = 1;
r2 = ifft(fft(app.wave1).*conj(fft(app.wave2)));%用FFT求相关函数
N2 = length(r2);
NN=length(app.wave1);
r3 = r2/NN;
x4= linspace(-T/2,T/2,N2);
xlim(app.UIAxes4,[-T/2,T/2]);
ylim(app.UIAxes4,[-1,1]);
plot(app.UIAxes4,x4,r3);
end
end
程序运行后出现的报错是
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/e35153330a3a4be989ec52b5a7518559.png "#left")