How can I remove the line for nan in my ploting
1 view (last 30 days)
Show older comments
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])
0 Comments
Accepted Answer
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;
mask1 = movmean(abs(real(y1_km)),2) > 0;
mask2 = movmean(abs(real(y3_km)),2) > 0;
x1 = padarray(x(mask1),[0 1],'replicate','both');
x2 = padarray(x(mask2),[0 1],'replicate','both');
plot (x1,padarray(real(y1_km(mask1)),[0 1],0,'both'),'r'); hold on
plot (x1,padarray(real(y2_km(mask1)),[0 1],0,'both'),'r')
plot (x2,padarray(real(y3_km(mask2)),[0 1],0,'both'),'g')
plot (x2,padarray(real(y4_km(mask2)),[0 1],0,'both'),'g')
xlabel('x (km)')
ylabel('y (km)')
xlim([0 22])
ylim([-3 3])
More Answers (2)
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.
1 Comment
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])
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!