matlab报错,The integrand function must return an output vector of the same length ...序如下syms f ; la1=1310*10^-9; c=3*10^8; x=0; %光程差 f1=c/la1;df=3.4*10^12; %谱宽la2=1311*10^-9; f2=c/la2;t=sqrt(exp((-(f-f1)*(f-f1)-(f-f2)*(f-f2))/(2*df*

来源:学生作业学帮网 编辑:学帮网 时间:2024/05/31 05:12:18

matlab报错,The integrand function must return an output vector of the same length ...序如下
syms f ;
la1=1310*10^-9;
c=3*10^8;
x=0; %光程差
f1=c/la1;
df=3.4*10^12; %谱宽
la2=1311*10^-9;
f2=c/la2;
t=sqrt(exp((-(f-f1)*(f-f1)-(f-f2)*(f-f2))/(2*df*df)))*cos(2*pi*x*f/c)/(sqrt(2*pi)*df);
y=quad(@(f) t,2.273076335877862*10^14,2.305329519450801*10^14)
报错:Error using quad (line 79)
The integrand function must return an output vector of the same length as the input vector.

>> la1=1310*10^-9;
c=3*10^8;
x=0; %光程差
f1=c/la1;
df=3.4*10^12; %谱宽
la2=1311*10^-9;
f2=c/la2;
t=@(f)abs(sqrt(exp((-(f-f1).*(f-f1)-(f-f2).*(f-f2))./(2.*df.*df))).*cos(2*pi*x*f/c)./(sqrt(2*pi)*df));
y=integral(t,2.273076335877862*10^14,2.305329519450801*10^14)
y =
0.3646