MATLAB: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

array

In the first part the codes work perfectly and it calculates all the forces Fp. In the second line the loop won't work, but I do the exact same thing.
Thanks for the help!
close all
clear all
%% Piston kracht
F1=100 %[N]
hoekF=90
slopearm=[0:1:90]
alpha=90-hoekF+slopearm
r=25
x=20
hoeksup=asind((3*sind(135-slopearm))/(square((x^2)+(3^2)-2*x*3*cosd(135-slopearm))))
beta=90-hoeksup
syms Fp
eqn=F1*cosd(alpha)*r==Fp*cosd(beta)*x
for K = 1 : length(eqn)
d(K) = double(vpasolve(eqn(K), Fp))
end
plot(slopearm,d)
title('Krachtverloop in bovenste piston')
%% Scharnier krachten F2 en F3
syms F2
Xs=F1*sind(alpha)+d*sind(beta)-F2*sind(alpha)==0
Ys=F1*cosd(alpha)-d*cosd(beta)-F2*cosd(alpha)==0
for A = 1 : length(Xs)
k(A) = double(vpasolve(Xs(A), F2))
end

Best Answer

The problem is that the first element of ‘Xs’:
4501354550746679/8796093022208 == 0
is not a function of ‘F2’, so it returns an empty element.
Beginning the loop at 2 (and preallocating ‘k’), iavoids that problem:
k = zeros(size(Xs));
for A = 2 : length(Xs)
k(A) = double(vpasolve(Xs(A), F2));
end
The first element of ‘k’ is now 0.