Can anyone help me to understand the logic of below code

조회 수: 1 (최근 30일)
VANDANA GUPTA
VANDANA GUPTA 2019년 6월 27일
댓글: Jan 2019년 7월 8일
Xb=Xm; Yb=Ym; Zb=Zm; % Boundary Points
Xf=[];Yf=[];Zf=[];
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
range of Xb = 12.75 to 26.75
range of Yb = -10 to 10
range of Zb = -10 to 10
  댓글 수: 6
VANDANA GUPTA
VANDANA GUPTA 2019년 7월 1일
편집: Guillaume 2019년 7월 1일
sir, i want to understand this portion of this code:
% 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
Guillaume
Guillaume 2019년 7월 1일
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 insert_code_16.png button.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2019년 7월 1일
Start with a simplification of the code to make it easier to read:
% find the points in the front surface
for z = min(Zb):max(Zb) + 0.5
% Get x, y, z values of points near to Zb==z:
index = (abs(Zb - z) < 0.01);
x1 = Xb(index);
y1 = Yb(index);
z1 = Zb(index);
for y = min(y1):max(y1) + 0.5
% Get x1, y1, z1 values of points near to y1==y:
index = (abs(y1-y) < 0.01);
x2 = x1(index);
y2 = y1(index);
z2 = z1(index);
% Get x2, y2, z2 values of points near to y2==min(x2):
index = (abs(x2-min(x2)) < 0.01);
xf = x2(index);
yf = y2(index);
zf = z2(index);
% Collect the xf, yf, zf values:
Xf = [Xf; xf];
Yf = [Yf; yf];
Zf = [Zf; zf];
end
end
  댓글 수: 2
VANDANA GUPTA
VANDANA GUPTA 2019년 7월 8일
ok, sir.......sir in the code of front surface, is vector size reduced of Xb,Yb and Zb upto x2, y2 and z2....and in xf, yf and zf, surface is getting
Jan
Jan 2019년 7월 8일
@VANDANA GUPTA: So do you have a specific question about the code?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by