“Dimensions of arrays being concatenated are not consistent”

조회 수: 1 (최근 30일)
Adam Steciuk
Adam Steciuk 2020년 4월 28일
댓글: Adam Steciuk 2020년 5월 1일
I am getting said error even thoug I don't think I am not concatenating any array.
wallCordsReal = [];
homoVecSen = [sonars(1); 0; 0; 1];
poser = gtposes(1,:);
transMatrix = Tsonar2univ(poser);
tempWall = transMatrix * homoVecSen;
And here is the function Tsonar2univ:
function transfMatrix = Tsonar2univ(poser)
global measured_offsx;
global measured_offsy;
global measured_offsphi;
%sonar origin relative to robot
RorgS = [measured_offsx; measured_offsy; 0];
UorgR = [poser(1); poser(2); 0];
RrS = [cos(measured_offsphi), sin(measured_offsphi), 0; -sin(measured_offsphi), cos(measured_offsphi), 0; 0, 0, 1]
UrR = [cos(poser(3)), -sin(poser(3)), 0; sin(poser(3)), cos(poser(3)), 0; 0, 0, 1];
RtS = zeros(4,4);
RtS(1:3, 1:3) = RrS;
RtS(1:3, 4) = RorgS;
UtR = zeros(4,4);
UtR(1:3, 1:3) = UrR;
UtR(1:3, 4) = UorgR;
UtR(4,4) = 1;
transfMatrix = UtR * RtS;
end

답변 (1개)

James Tursa
James Tursa 2020년 4월 28일
TYpe this at the command line:
dbstop if error
then run your code. When the error occurs the code will pause with all current variables intact. Examine measured_offsphi and you will probably see it is not a scalar. Then backtrack in your code and figure out why.
  댓글 수: 6
James Tursa
James Tursa 2020년 4월 30일
Well, did you do what I suggested in my very first post? That puts you in the debugger where you can figure things out.
Adam Steciuk
Adam Steciuk 2020년 5월 1일
I just decided to scrap idea of global variables and passed values as function arguments. And it worked

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by