# How can I remove the line for nan in my ploting

2 views (last 30 days)
Abdullah Alsayegh on 24 Feb 2022
Commented: Walter Roberson on 24 Feb 2022
How can i remove the line that is center in my plot. I am assuming its because of the nan values so how can I remove it from the plotting?
mdot = 115; % Source Strength g/s
U = 6.82; % Wind speed m/s
h = 80; % Stack Height (m)
Sh = 20; % Plume Rise Height (m)
H = h + Sh; % Effective Stack Height (m)
x = 0:0.1:22; % X location (m)
Cj = 25*10.^-6; % Y location (m)
z = 0; % Z location (m)
% Dispersion Coefficients
a = 68;
b = 0.894;
c = 44.5;
d = 0.516;
f = -13;
% Dispersion Coefficients
sigmaY = a * (x.^b);
sigmaZ = c * (x.^d) + f;
y1 = 2.^(1./2).*sigmaY.*(-log((2.*Cj.*U.*sigmaY.*sigmaZ.*pi)./(mdot.*(exp(-H.^2./(2.*sigmaZ.^2)).*exp((H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)) + exp(-H.^2./(2.*sigmaZ.^2)).*exp(-(H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)))))).^(1./2);
y2 = -2.^(1./2).*sigmaY.*(-log((2.*Cj.*U.*sigmaY.*sigmaZ.*pi)./(mdot.*(exp(-H.^2./(2.*sigmaZ.^2)).*exp((H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)) + exp(-H.^2./(2.*sigmaZ.^2)).*exp(-(H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)))))).^(1./2);
y3 = (sigmaY.*(2.*H.*z - 2.*sigmaZ.^2.*log((2.*pi.*Cj.*U.*sigmaY.*sigmaZ)./mdot) - H.^2 - z.^2).^(1./2))./sigmaZ;
y4 = -(sigmaY.*(2.*H.*z - 2.*sigmaZ.^2.*log((2.*pi.*Cj.*U.*sigmaY.*sigmaZ)./mdot) - H.^2 - z.^2).^(1/2))./sigmaZ;
y1_km = y1*10^-03;
y2_km = y2*10^-03;
y3_km = y3*10^-03;
y4_km = y4*10^-03;
plot (x,y1_km,'r',x,y2_km,'r',x,y3_km,'g',x,y4_km,'g')
xlabel('x (km)')
ylabel('y (km)')
xlim([0 22])
ylim([-3 3])

DGM on 24 Feb 2022
Edited: DGM on 24 Feb 2022
This is one way
mdot = 115; % Source Strength g/s
U = 6.82; % Wind speed m/s
h = 80; % Stack Height (m)
Sh = 20; % Plume Rise Height (m)
H = h + Sh; % Effective Stack Height (m)
x = 0:0.1:22; % X location (m)
Cj = 25*10.^-6; % Y location (m)
z = 0; % Z location (m)
% Dispersion Coefficients
a = 68;
b = 0.894;
c = 44.5;
d = 0.516;
f = -13;
% Dispersion Coefficients
sigmaY = a * (x.^b);
sigmaZ = c * (x.^d) + f;
y1 = 2.^(1./2).*sigmaY.*(-log((2.*Cj.*U.*sigmaY.*sigmaZ.*pi)./(mdot.*(exp(-H.^2./(2.*sigmaZ.^2)).*exp((H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)) + exp(-H.^2./(2.*sigmaZ.^2)).*exp(-(H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)))))).^(1./2);
y2 = -2.^(1./2).*sigmaY.*(-log((2.*Cj.*U.*sigmaY.*sigmaZ.*pi)./(mdot.*(exp(-H.^2./(2.*sigmaZ.^2)).*exp((H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)) + exp(-H.^2./(2.*sigmaZ.^2)).*exp(-(H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)))))).^(1./2);
y3 = (sigmaY.*(2.*H.*z - 2.*sigmaZ.^2.*log((2.*pi.*Cj.*U.*sigmaY.*sigmaZ)./mdot) - H.^2 - z.^2).^(1./2))./sigmaZ;
y4 = -(sigmaY.*(2.*H.*z - 2.*sigmaZ.^2.*log((2.*pi.*Cj.*U.*sigmaY.*sigmaZ)./mdot) - H.^2 - z.^2).^(1/2))./sigmaZ;
y1_km = y1*10^-03;
y2_km = y2*10^-03;
y3_km = y3*10^-03;
y4_km = y4*10^-03;
xlabel('x (km)')
ylabel('y (km)')
xlim([0 22])
ylim([-3 3])
##### 2 CommentsShowHide 1 older comment
DGM on 24 Feb 2022
Edited.

Walter Roberson on 24 Feb 2022
Warning: Imaginary parts of complex X and/or Y arguments ignored.
You are plotting complex values and you are assuming that it will not plot any location where either x or y has a non-zero imaginary part. But instead it plots using the real part of the values.
Walter Roberson on 24 Feb 2022
mdot = 115; % Source Strength g/s
U = 6.82; % Wind speed m/s
h = 80; % Stack Height (m)
Sh = 20; % Plume Rise Height (m)
H = h + Sh; % Effective Stack Height (m)
x = 0:0.1:22; % X location (m)
Cj = 25*10.^-6; % Y location (m)
z = 0; % Z location (m)
% Dispersion Coefficients
a = 68;
b = 0.894;
c = 44.5;
d = 0.516;
f = -13;
% Dispersion Coefficients
sigmaY = a * (x.^b);
sigmaZ = c * (x.^d) + f;
y1 = 2.^(1./2).*sigmaY.*(-log((2.*Cj.*U.*sigmaY.*sigmaZ.*pi)./(mdot.*(exp(-H.^2./(2.*sigmaZ.^2)).*exp((H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)) + exp(-H.^2./(2.*sigmaZ.^2)).*exp(-(H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)))))).^(1./2);
y2 = -2.^(1./2).*sigmaY.*(-log((2.*Cj.*U.*sigmaY.*sigmaZ.*pi)./(mdot.*(exp(-H.^2./(2.*sigmaZ.^2)).*exp((H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)) + exp(-H.^2./(2.*sigmaZ.^2)).*exp(-(H.*z)./sigmaZ.^2).*exp(-z.^2./(2.*sigmaZ.^2)))))).^(1./2);
y3 = (sigmaY.*(2.*H.*z - 2.*sigmaZ.^2.*log((2.*pi.*Cj.*U.*sigmaY.*sigmaZ)./mdot) - H.^2 - z.^2).^(1./2))./sigmaZ;
y4 = -(sigmaY.*(2.*H.*z - 2.*sigmaZ.^2.*log((2.*pi.*Cj.*U.*sigmaY.*sigmaZ)./mdot) - H.^2 - z.^2).^(1/2))./sigmaZ;
y1_km = y1*10^-03;
y2_km = y2*10^-03;
y3_km = y3*10^-03;
y4_km = y4*10^-03;
y1_km(imag(y1_km)~=0) = nan;
y2_km(imag(y2_km)~=0) = nan;
y3_km(imag(y3_km)~=0) = nan;
y4_km(imag(y4_km)~=0) = nan;
plot (x,y1_km,'r',x,y2_km,'r',x,y3_km,'g',x,y4_km,'g')
xlabel('x (km)')
ylabel('y (km)')
xlim([0 22])
ylim([-3 3])

KSSV on 24 Feb 2022
Edited: KSSV on 24 Feb 2022
% remove that line
idx = x>11.3 ;
y3_km(idx) = NaN ;
y4_km(idx) = NaN ;