MATLAB: Vertcat error, can’t find what’s wrong, new to MATLAB

dimensionerrorMATLABmismatchvertcat

Here is the whole error I am getting:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in mcdon898_HW6 (line 12)
F = [2.85*A(1,1)*sin(A(2,1))-0.285*A(1,1)*cos(A(2,1))+0.285*(A(1,1)^2)+1.919*A(1,1)*A(3,1)*sin(A(2,1)-A(4,1))-0.24;
I looked around online for this error and it seems MATLAB is saying that I am trying to concentenate 2 matrices, but I'm not (at least not intentionally!). When I look around my code, I can't find anything wrong. I am basing this code off of a simpler code I wrote before that worked great. This is the most complicated thing I've done in MATLAB though, and I have not used it much, so I am wondering if I am just completely missing something. Here is my code:
%Initialize variables
A = [1; 0.1; 1; 0.1; 0.1;];
%Newton-Rapson calculation starts here
while 1
%Create matrix of functions
F = [2.85*A(1,1)*sin(A(2,1))-0.285*A(1,1)*cos(A(2,1))+0.285*(A(1,1)^2)+1.919*A(1,1)*A(3,1)*sin(A(2,1)-A(4,1))-0.24;
-0.285*A(1,1)*sin(A(2,1))-2.85*A(1,1)*cos(A(2,1))-4.7688*(A(1,1)^2)-1.919*A(1,1)*A(3,1)*cos(A(2,1)-A(4,1))-0.1;
1.919*A(1,1)*A(3,1)*sin(A(4,1)-A(2,1))+0.198*(A(3,1)^2)+2,282*A(3,1)*sin(A(4,1)-A(5,1))-0.19*A(3,1)*cos(A(4,1)-A(5,1))-0.4;
-1.919*A(1,1)*A(3,1)*cos(A(4,1)-A(2,1))+4.3008*(A(3,1)^2)-2.282*A(3,1)*cos(A(4,1)-A(5,1))-0.19*A(3,1)*sin(A(4,1)-A(5,1))-0.1;
0.182+2.282*A(3,1)*sin(A(5,1)-A(4,1))-0.19*A(3,1)*cos(A(5,1)-A(4,1))+0.6;];
%Create Jacobian matrix
J = [2.85*sin(A(2,1))-0.285*cos(A(2,1))+0.57*A(1,1)+1.919*A(3,1)*sin(A(2,1)-A(4,1))
1.9198*A(1,1)*A(3,1)*cos(A(2,1)-A(4,1))+0.285*A(1,1)*sin(A(2,1))+2.85*A(1,1)*cos(A(2,1))
1.919*A(1,1)*sin(A(2,1)-A(4,1))
-1.919*A(1,1)*A(3,1)*cos(A(2,1)-A(4,1))
0;
-0.285*sin(A(2,1))-2.85*cos(A(2,1))-9.5376*A(1,1)-1.919*A(3,1)*cos(A(2,1)-A(4,1))
2.85*A(1,1)*sin(A(2,1))+1.919*A(1,1)*A(3,1)*sin(A(2,1)-A(4,1))-0.285*A(1,1)*cos(A(2,1))
-1.919*A(1,1)*cos(A(2,1)-A(4,1))
-1.919*A(1,1)*A(3,1)*sin(A(2,1)-A(4,1))
0;
1.919*A(3,1)*sin(A(4,1)-A(2,1))
-1.919*A(1,1)*A(3,1)*cos(A(4,1)-A(2,1))
1.919*A(1,1)*sin(A(4,1)-A(2,1))+0.396*A(3,1)+2.282*sin(A(4,1)-A(5,1))-0.19*cos(A(4,1)-A(5,1))
1.919*A(1,1)*A(3,1)*cos(A(4,1)-A(2,1))+0.19*A(3,1)*sin(A(4,1)-A(5,1))+2.282*A(3,1)*cos(A(4,1)-A(5,1))
-0.19*A(3,1)*sin(A(4,1)-A(5,1))-2.282*A(3,1)*cos(A(4,1)-A(5,1));
-1.919*A(3,1)*cos(A(4,1)-A(2,1))
-1.919*A(1,1)*A(3,1)*sin(A(4,1)-A(2,1))
-1.919*A(1,1)*cos(A(4,1)-A(2,1))+8.6016*A(3,1)-2.282*cos(A(4,1)-A(5,1))-0.19*sin(A(4,1)-A(5,1))
1.919*A(1,1)*A(3,1)*sin(A(4,1)-A(2,1))+2.282*A(3,1)*sin(A(4,1)-A(2,1))-0.19*A(3,1)*cos(A(4,1)-A(5,1))
0.19*A(3,1)*cos(A(4,1)-A(5,1))-2.282*A(3,1)*sin(A(4,1)-A(5,1));
0
0
2.282*sin(A(5,1)-A(4,1))-0.19*cos(A(5,1)-A(4,1))
-0.19*A(3,1)*sin(A(5,1)-A(4,1))-2.282*A(3,1)*cos(A(5,1)-A(4,1))
2.282*A(3,1)*cos(A(5,1)-A(4,1))+0.19*A(3,1)*sin(A(5,1)-A(4,1));];
%Do calculation
A = A - (J^-1)*F;
%Check condition
if (F(1,1)<0.001 && F(2,1)<0.001 && F(3,1)<0.001 && F(4,1)<0.001 && F(5,1)<0.001)
break
end
end
%Display variables in comamand window
disp(A)

Best Answer

your mistake is to place a "," instead of a decimal point 2.282 instead of 2,282
F = [2.85*A(1,1)*sin(A(2,1))-0.285*A(1,1)*cos(A(2,1))+0.285*(A(1,1)^2)+1.919*A(1,1)*A(3,1)*sin(A(2,1)-A(4,1))-0.24;
-0.285*A(1,1)*sin(A(2,1))-2.85*A(1,1)*cos(A(2,1))-4.7688*(A(1,1)^2)-1.919*A(1,1)*A(3,1)*cos(A(2,1)-A(4,1))-0.1;
1.919*A(1,1)*A(3,1)*sin(A(4,1)-A(2,1))+0.198*(A(3,1)^2)+2.282*A(3,1)*sin(A(4,1)-A(5,1))-0.19*A(3,1)*cos(A(4,1)-A(5,1))-0.4;
-1.919*A(1,1)*A(3,1)*cos(A(4,1)-A(2,1))+4.3008*(A(3,1)^2)-2.282*A(3,1)*cos(A(4,1)-A(5,1))-0.19*A(3,1)*sin(A(4,1)-A(5,1))-0.1;
0.182+2.282*A(3,1)*sin(A(5,1)-A(4,1))-0.19*A(3,1)*cos(A(5,1)-A(4,1))+0.6;];