It would be a lot more readable with one instruction per line than 3 instructions per line. Also you haven't given any indication where the code comes from. It's a waste of time for us trying to understand the logic in unidentified 3rd party code - there's no guarantee it actually has any logic and isn't just garbage code!
% Showing the front surface only where signals being reflected
Xb=Xm; Yb=Ym; Zb=Zm; % boundary points
Xf=[ ]; Yf=[ ]; Zf=[ ];
% find the points in the front surface
for z=min(Zb):1:max(Zb)+0.5
x1=Xb(abs(Zb-z)<0.01);
y1=Yb(abs(Zb-z)<0.01);
z1=Zb(abs(Zb-z)<0.01);
for y=min(y1):1:max(y1)+0.5
x2=x1(abs(y1-y)<0.01);
y2=y1(abs(y1-y)<0.01);
z2=z1(abs(y1-y)<0.01);
xf=x2(abs(x2-min(x2))<0.01);
yf=y2(abs(x2-min(x2))<0.01);
zf=z2(abs(x2-min(x2))<0.01);
Xf=[Xf; xf]; Yf=[Yf; yf]; Zf=[Zf; zf];
end
end
plot3(Xm,Ym,Zm,'.k' )
hold on
X1=[Xf(1), Xf(1),Xf(1),Xf(1)];
Y1=[min(Yf), min(Yf),max(Yf), max(Yf)];
Z1=[min(Zf), max(Zf),max(Zf), min(Zf)];
fill3(X1, Y1, Z1, 'r')
sir i want to understand the matlab code for making front surface..how ''abs(Zb-z)<0.01, abs(y1-y)<0.01, abs(x2-min(x2))<0.01'' these conditions work exactly in the code
It calculates some stuff. Now, since you still haven't told us what the overall purpose of the code is, I doubt anybody is going to bother looking any deeper. Well written code would have comment explaining what the variables are (and have better variable names) and comments explaining what's going on. This hasn't
I suggest that if you need help understanding the code, you ask whoever wrote it.
Oh, and please use the toolbar to format the code as code. It's the button.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
6 Comments
Adam (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/469120-can-anyone-help-me-to-understand-the-logic-of-below-code#comment_718889
VANDANA GUPTA (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/469120-can-anyone-help-me-to-understand-the-logic-of-below-code#comment_719974
KALYAN ACHARJYA (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/469120-can-anyone-help-me-to-understand-the-logic-of-below-code#comment_719985
VANDANA GUPTA (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/469120-can-anyone-help-me-to-understand-the-logic-of-below-code#comment_719986
VANDANA GUPTA (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/469120-can-anyone-help-me-to-understand-the-logic-of-below-code#comment_720010
Guillaume (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/469120-can-anyone-help-me-to-understand-the-logic-of-below-code#comment_720014
Sign in to comment.