Нахождение местоположения максимума контурного участка - PullRequest
0 голосов
/ 05 апреля 2019

Я выяснил большую часть своего кода, но я не знаю, что вставить в скобки в конце кода для x () и y (), чтобы найти расположение максимумов в контуре

Это код Matlab, созданный моим профессором, и мне пришлось заполнить большинство пробелов в нем.Я не знаком с MATLAB, поэтому я понятия не имею, в чем смысл x () и y ().Я также попытался просмотреть руководства MATLAB.

% Project: Modeling pollutant concentration with Gaussian model
% The Table numbers refer to the handouts on "Air Pollution", available on BB

clear
clc

% input variables
Q= 500*10^6 ; %source emission rate (ug/s)
H=120  ; %effective stack height (m)


% define spatial domain
xlength= 10000;  % domain length (m) --> 10km
ylength= 4000;  % domain width (m) --> 2 km on either side of the plume centerline
dx= 100;        % x node spacing (m)
dy= 100;        % y node spacing (m)
x=0:dx:xlength; %(m)
x(1)=1;
y=-ylength/2:dy:ylength/2; %(m)


% calculate windspeed at z=H for stability classes A, C, F
% ground-level windspeeds (at z=10 m)
GLwindspeed=[2 2 2]; %(m/s)


% uH/ua=(H/za)^p, so uH=ua*(H/za)^p. ua=anemometer height=GLwindspeed
% exponent p varies with stability class

p=[0.15 0.20 0.60]; % from Table 7.6
za=  10 ; % standard anemometer height, (m)


for i=1:3 % # of stability classes to be considered
    uH(i)=GLwindspeed(i)*(H/za)^p(i); %wind speed at effective stack height (m)
end


% coefficients a, c, d, f for calculation of sigma y and z (Table 7.8)
coeff_a=[213 104 34]; % coefficient a doesn't depend on the downwind distance x 
coeff_c=[440.8 61.0 14.35 ; 459.7 61.0 62.6]; % different coefficients for x<=1km and x>1km
coeff_d=[1.941 0.911 0.740 ; 2.094 0.911 0.180];  % different coefficients for x<=1km and x>1km
coeff_f=[9.27 0 -0.35 ; -9.6 0 -48.6];  % different coefficients for x<=1km and x>1km


%calculate the pollutant concentration C for entire domain (and the three stability classes)

for st=1:3  % st = # of stability class (A, C, F)

    for i=1:length(x)

        sigmaY=coeff_a(st)*(x(i)/1000)^0.894; % coefficients of sigma Y  doesn't depend on the downwind distance x 

        % parameters in the empirical formula for sigma Z depend on the downwind distance x: 
        if x(i)<=1000 %(m)
            sigmaZ=coeff_c(1,st)*(x(i)/1000)^coeff_d(1,st)+coeff_f(1,st);
        else
            sigmaZ=coeff_c(2,st)*(x(i)/1000)^coeff_d(2,st)+coeff_f(2,st);
        end

        for j=1:length(y)

            C(i,j,st)=Q/(pi*sigmaY*sigmaZ*uH(st))*exp(-y(j)^2/(2*sigmaY^2))*2*exp(-H^2/(2*sigmaZ^2));

        end
    end
end


% Contour Plots
for st=1:3
    figure
    contour(y,x,C(:,:,st))
    colorbar
    title('Downwind Pollutant Concentration','FontSize',18)
    xlabel('Downwind Width (m)','FontSize',18);
    ylabel('Downwind Distance (m)','FontSize',18)
    set(gca,'FontSize',12)
end

% Peak concentrations:
peak_classA= max(max(C(:,:,1)))
peak_classC= max(max(C(:,:,2)))
peak_classF= max(max(C(:,:,3)))

% Location of peak concentrations:
[iA,jA]=find(C(:,:,1)==peak_classA);
x(   )
y(   )

[iC,jC]=find(C(:,:,2)==peak_classC);
x(   )
y(   )

[iF,jF]=find(C(:,:,3)==peak_classF);
x(   )
y(   )

1 Ответ

0 голосов
/ 05 апреля 2019

Команда 'find' возвращает индекс, используя этот индекс, мы находим значения x и y.

% Location of peak concentrations:
[iA,jA]=find(C(:,:,1)==peak_classA);
x(iA) %Finds the x value at the index iA
y(jA) %Finds the y value at the index jA

[iC,jC]=find(C(:,:,2)==peak_classC);
x(iC)
y(jC)

[iF,jF]=find(C(:,:,3)==peak_classF);
x(iF)
y(jF)

Для класса A это возвращает

ans =

   400


ans =

     0

При осмотре участка (0,400), кажется, подходит!

plot1

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...