Matlab中有子函数如何写主函数

function TimeAnalysis()
global SamplingFreq IF SatelliteNum FreqBand StartMs AnalysisMs ReadLengthMs AcquireBW StandardFreq
fb=IF;
fs=SamplingFreq;
fstan=StandardFreq;
f0=fb-fs;
LL=20;
switch FreqBand
case 4
load Local_E1I1.mat
load Local_E1I2.mat
load Local_E1Q.mat
load s_demoE1.mat
s1=real(s_demoE1);
s2=imag(s_demoE1);
Bandwide_filter=32.736e+6;
n1=fs/1000*4;
n2=fs/1000*2;
fc1=1*fstan;
fc2=2.5*fstan;
[MM NN]=max(abs(xcorr(Local_E1I1(1:n1),s1(1:n1))));
[MM1 NN1]=max(abs(xcorr(Local_E1I2(1:n1),s1(1:n1))));
if abs(MM)>=abs(MM1)
Local_E1I=Local_E1I1(1:n1);
else
Local_E1I=Local_E1I2(1:n1);
end
if max(xcorr(Local_E1I(1:n1),s1(1:n1)))-max(abs(xcorr(Local_E1I(1:n1),s1(1:n1))))~=0
Local_E1I=-Local_E1I;
end
Local_E1I=sqrt(2)/3*Local_E1I;
Local_E1I_filter=lp_filter(Bandwide_filter/2,Local_E1I(1:n1));
if max(xcorr(Local_E1Q(1:n2),s2(1:n2)))-max(abs(xcorr(Local_E1Q(1:n2),s2(1:n2))))~=0
Local_E1Q=-Local_E1Q;
end
Local_E1Q=2/3*Local_E1Q;
Local_E1Q_filter=lp_filter(Bandwide_filter/2,Local_E1Q(1:n2));
%%%%%%%%%时域波形及信噪比
figure
plot(s1(1:ceil(fs/fc1)*LL),'r')
hold on
plot(Local_E1I(1:ceil(fs/fc1)*LL),'b-.','LineWidth',1.5)
hold on
plot(Local_E1I_filter(1:ceil(fs/fc1)*LL),'k')
legend
title;
figure
plot(s2(1:ceil(fs/fc2)*LL),'r')
hold on
plot(Local_E1Q(1:ceil(fs/fc2)*LL),'b-.','LineWidth',1.5)
hold on
plot(Local_E1Q_filter(1:ceil(fs/fc2)*LL),'k')
legend
title;
snr1=SNR(Local_E1I(1:n1),s1(1:n1))
snr2=SNR(Local_E1I_filter(1:n1),s1(1:n1))
histgramFigure(s1(1:n1))
histgramFigure(s2(1:n2))
eyeFigure(s1(1:n1),fs,fc1)
eyeFigure(s2(1:n2),fs,fc2)
end

function [a,b,c]=OUTPUT(e,f) %abc 为输出参数,ef为输入参数(根据需要,可有可无)
.......
a=?; %输出参数一定要幅值!
b=?;
c=?;
end
在主程序里,调用格式为:[a,b,c]=OUTPUT(e,f)
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-04-16
Matlab不像C那样有个main()的主函数,你只有写个m文件,在该文件中就可以调用你写得其他函数了(注意路径就是了。)追问

主要是针对这个程序,我不知道再写一个什么样的程序才可以运行。

相似回答