clc;
c = 2.997924562e8; %Speed of Light 光速
dtor = pi/180; %5角度转换为弧度
% GrAng=app.GrAngEditField.Value;
GrAng=app.GrAngSlider.Value;
app.currentNumEditField.Value=GrAng;
phi=app.phiSpinner.Value;
ThWind =app.ThWindSpinner.Value;
Pol=app.PolDropDown.Value;
% GrAng =[0.3];
NGrAng = length(GrAng);%定义擦射角的数组的长度
% ThWind = 0;
% phi = 0;

% freq = (0.5:0.1:40);
% freq = app.fromEditField.Value;
fx=app.fromSpinner.Value;
step=app.stepSpinner.Value;
fm=app.ToSpinner.Value;
freq = (fx:step:fm);%fx为起始值,step为步长,fm为序列的结束值
fMin=freq(1);
fMax=max(freq);
fMax=freq(end);

% Variables for computing average abs deviation 计算平均误差
SumDevH = 0.0;
NValH = 0;
SumDevV = 0.0;
NValV = 0;

phi_rad = phi .* dtor;
% GRAPHICS DEFINITIONS 图形定义
ha=[];hl=[];hp=[];ht=[];htx=[];hty=[];
set(0,'Units','pixels')

% Set SCreen Size 定义屏幕尺寸
scnsize=get(0,'ScreenSize');
pos1 = [5+scnsize(1),0.02scnsize(4),.99scnsize(3),.75*scnsize(4)];

FigFont = 28;
CircSize = 14;
LineSize = 7;
AxWidth = 4;

% Initialize figure number 初始化图号

% Defines units for values returned by ScreenSize 定义ScreenSize返回值的单位

% Define colors for curves and points 定义曲线和点的颜色
Cols = 'bgrcmyk';

ColsMat = [ 0.161 0.698 0.725; % magenta
0.608 0.18 0.8; % violet
1.0 0.0 0.0; % red
0.541 0.416 0.361; % brown
0.0 0.0 0.0; % black
1 0 1;% dark green
0.067 0.204 0.898 ];% dark blue
cla(app.UIAxes14, 'reset');
cla(app.UIAxes_4, 'reset');
cla(app.UIAxes14_2, 'reset');
cla(app.UIAxes14_3, 'reset');
cla(app.UIAxes14_4, 'reset');
%########################################################################
% ALL GRAZING ANGLES 所有的擦射角
% Do all sea states for HH H极化下的海况。
%% GIT
for SeaSt=0:6
SeaState=SeaSt;
SS_Plus1 = SeaState + 1;

for ifreq = 1 : length(freq)
GTI_SigZHor(ifreq) = GTI_SigmaSea(freq(ifreq),SeaState,Pol,alpha,ThWind);
end

GTI_SigmaHH = GTI_SigZHor;

% Plot empirical curve first
semilogx(app.UIAxes14,freq,GTI_SigmaHH,'Color',ColsMat(SeaSt+1,:));
legend(app.UIAxes14,'GrAng =0.3 SeaState=1','GrAng =0.3 SeaState=2','GrAng =0.3 SeaState=3','GrAng =0.3 SeaState=4','GrAng =0.3 SeaState=5','GrAng =0.3 SeaState=6',Location='southeast')
hold(app.UIAxes14,"on")
grid(app.UIAxes14,'on');
xlabel(app.UIAxes14,'频率(GHz) ','FontSize',14);
ylabel(app.UIAxes14,'散射系数 - \sigma_{HH}^o (dB)','FontSize',14);
title(app.UIAxes14,'GIT模型HH极化','FontSize',14)
end
%% NRL
for SeaSt=0:6
SeaState=SeaSt;
SS_Plus1 = SeaState + 1;

NRL_SigZHor = NRL_SigmaSea(freq,SeaState,Pol,alpha);
NRL_SigmaHH=NRL_SigZHor;

% Plot empirical curve first

hl(end+1) = semilogx(app.UIAxes14_2,freq,NRL_SigmaHH);
legend(app.UIAxes14_2,'GrAng =0.3 SeaState=1','GrAng =0.3 SeaState=2','GrAng =0.3 SeaState=3','GrAng =0.3 SeaState=4','GrAng =0.3 SeaState=5',Location='southeast')
hold(app.UIAxes14_2,"on")
xlabel(app.UIAxes14_2,'频率(GHz) ','FontSize',14);
ylabel(app.UIAxes14_2,'散射系数 - \sigma_{HH}^o (dB)','FontSize',14);
title(app.UIAxes14_2,'NRL模型HH极化','FontSize',14)
grid(app.UIAxes14_2,'on');
end
%% HYB
for SeaSt=0:6
SeaState=SeaSt;
SS_Plus1 = SeaState + 1;

for ifreq = 1 : length(freq)
HYB_SigZHor(ifreq) = HYB_SigmaSea(freq(ifreq),SeaState,Pol,alpha,ThWind);
end
HYB_SigmaHH=HYB_SigZHor;
% Plot empirical curve first
hl(end+1) = semilogx(app.UIAxes14_3,freq,HYB_SigmaHH);
legend(app.UIAxes14_3,'GrAng =0.3 SeaState=1','GrAng =0.3 SeaState=2','GrAng =0.3 SeaState=3','GrAng =0.3 SeaState=4','GrAng =0.3 SeaState=5',Location='southeast')
hold(app.UIAxes14_3,"on")
xlabel(app.UIAxes14_3,'频率(GHz) ','FontSize',14);
ylabel(app.UIAxes14_3,'散射系数 - \sigma_{HH}^o (dB)','FontSize',14);
title(app.UIAxes14_3,'HYB模型HH极化','FontSize',14)
grid(app.UIAxes14_3,'on');
end
%% TSC
for SeaSt=0:6
SeaState=SeaSt;
SS_Plus1 = SeaState + 1;

for ifreq = 1 : length(freq)
TSC_SigZHor(ifreq) = TSC_SigmaSea(freq(ifreq),SeaState,Pol,alpha,ThWind);
end
TSC_SigmaHH=TSC_SigZHor;
% Plot empirical curve first
hl(end+1) = semilogx(app.UIAxes14_4,freq,TSC_SigmaHH);
legend(app.UIAxes14_4,'GrAng =0.3 SeaState=1','GrAng =0.3 SeaState=2','GrAng =0.3 SeaState=3','GrAng =0.3 SeaState=4','GrAng =0.3 SeaState=5',Location='southeast')
hold(app.UIAxes14_4,"on")
% set(hl(end),'Color',ColsMat(SeaSt+1,:));
xlabel(app.UIAxes14_4,'频率(GHz) ','FontSize',14);
ylabel(app.UIAxes14_4,'散射系数 - \sigma_{HH}^o (dB)','FontSize',14);
title(app.UIAxes14_4,'TSC模型HH极化','FontSize',14)
grid(app.UIAxes14_4,'on');
end