Dimensions of arrays being concatenated are not consistent.

조회 수: 4 (최근 30일)
farzad jalizi
farzad jalizi 2021년 7월 15일
편집: Jan 2021년 7월 16일
Hello, attached is my code and actually the code works, but after a few rounds in for an error message appears.
''Dimensions of arrays being concatenated are not consistent.''
function w=deformation(x,y,z,H,curv,R,meshlense)% x,y,z are the tool reference positions ztool is the shape of the tool (where the curvature is inputed) R is the radius of the tool
%x=feed*cos(theta)// or as x y input
%y=feed*sin(theta)
T=[1 0 0 -x; 0 1 0 -y; 0 0 -1 z; 0 0 0 1];%transformation matrix lense to tool
%0 1 0 -y;...
%0 0 -1 z;...
%0 0 0 1];
step=meshlense.x(2)-meshlense.x(1);
[n,m]=size(meshlense.z);
w.z=zeros(n,m);
w.t=zeros(n,m);
for i=1:1:n % to sweep over the tool
for j=1:1:m % condition to be on tool and on lense comparing Radius of lense then Radius of tool
if (((n-1)*step/2)^2-((j-1)*step+meshlense.y(1))^2-((i-1)*step+meshlense.x(1))^2)>0 && (R^2-(y-((j-1)*step+meshlense.y(1)))^2-(x-((i-1)*step+meshlense.x(1)))^2)>0
i
j
Behzad = [meshlense.x(i);meshlense.y(j);meshlense.z(i,j); 1] ;
toolref=T*Behzad;
deltaz=toolref(3)-ztool(meshlense.x(i),meshlense.y(j),curv,2*R);
w.z(i,j)=H-deltaz; % to find the deformation at point x,y by calculating the heght between hard plastic and lense then comparing with original height
if deltaz<0
w.t(i,j)=0; % plastic of tool passes thru the lense; wenn deltaz<0, dann sitzt Linse direkt auf Werkzeug auf w.t = 0
elseif w.z(i,j)<0 %Wenn w.z <0 dann findet keine Berührung statt , denn das Werkzeug ist angehoben
w.z(i,j)=0; % if tool is lifted
w.t(i,j)=4;
else
w.t(i,j)=1; % there is normal deformation, ansonsten ist normale Deformation
end
elseif (((n-1)*step/2)^2-((j-1)*step+meshlense.y(1))^2-((i-1)*step+meshlense.x(1))^2)<0
if (R^2-(y-((j-1)*step+meshlense.y(1)))^2-(x-((i-1)*step+meshlense.x(1)))^2)>0
w.t(i,j)=2; % is off lense and on tool
else
w.t(i,j)=3; % is off lense but off tool
end
else
w.t(i,j)=-1; % is on lense but off tool
end
end
end
  댓글 수: 3
farzad jalizi
farzad jalizi 2021년 7월 15일
Thanks for your attention.
Error:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in deformation (line 7)
T=[1 0 0 -x; 0 1 0 -y; 0 0 1 -z; 0 0 0 0];%transformation matrix lense to tool
Mathieu NOE
Mathieu NOE 2021년 7월 15일
seems to me x,y,z should always be scalar , which may not be true after a few rounds
check dimensions during the iterations...

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

답변 (1개)

Jan
Jan 2021년 7월 16일
편집: Jan 2021년 7월 16일
Use the debugger to check your code:
dbstop if error
Start your program after typing this in the command window. When Matlab stops, check the sizes of x, y, z:
size(x)
size(y)
size(z)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by