找到最大等高线图的位置

问题描述 投票:0回答:1

我已经找到了大部分代码,但我不知道在x()和y()的代码末尾的括号中插入什么来查找轮廓中maxes的位置

这是我教授预先制作的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(   )
matlab contour
1个回答
0
投票

'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

© www.soinside.com 2019 - 2024. All rights reserved.