function [ ForAnalysis ] = Roughness( ERP,RH,ID,Message )
%Rhoughness Help
%   给出管道流量观测的相对误差ERP，和水位测量的精度ERH，用蒙特卡洛模拟出J，X1，X2，X3，X4，X5
%   ERP：管道流量观测的相对误差，取值为0或0.0005
%   RH：水位测量的相对误差，取值为0或0.0001
%   ID：需要截取的实验场次，取值范围为1~40
%   Message：需要截取的上下游断面标号，取值为1-2或1-3或2-3

[Vel1,Vel2,SW1,SW2]=DataOperator1(ERP,RH,ID,Message);
switch Message
    case '1-2'
        dX=5;
    case '2-3'
        dX=5;
    case '1-3'
        dX=10;
end
dT=5;

[~,Col]=size(Vel1);
for i=1:1:Col;
    U1=Vel1{i};
    U2=Vel2{i};
    H1=SW1{i};
    H2=SW2{i};
    
    %用连续性方程计算V2
    [Row,~]=size(Vel1{i});
    
    for j=2:1:Row
        H(j-1)=(H1(j)+H1(j-1)+H2(j)+H2(j-1))/4;
        Ht(j-1)=(H1(j)+H2(j)-H1(j-1)-H2(j-1))/(2*dT);
        Hx(j-1)=(H2(j)+H2(j-1)-H1(j)-H1(j-1))/(2*dX);
        
        U(j-1)=(U1(j)+U1(j-1)+U2(j)+U2(j-1))/4;
        Ut(j-1)=(U1(j)+U2(j)-U1(j-1)-U2(j-1))/(2*dT);
        Ux(j-1)=(U2(j)+U2(j-1)-U1(j)-U1(j-1))/(2*dX);
    end
    
    %计算公式中的各项
    J=-(Ut+U.*Ux+9.8.*Hx);
    X1=U.*U./H;
    X2=X1.*Hx;
    X3=U.*Ht./H;
    %X4=U.*Ux;
    X4=Ut;
    ForAnalysis{i}=[J',X1',X2',X3',X4'];
    
    clear H;
    clear Ht;
    clear Hx;
    clear U;
    clear Ut;
    clear Ux;
end


end

