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

1 回表示 (過去 30 日間)
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

採用された回答

Star Strider
Star Strider 2020 年 3 月 12 日
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.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 3 月 12 日
alpha starts out 0. sind(0) is 0. Multiply by F2 and you get 0. Therefore the equation becomes independent of the variable you are trying to solve for and so vpasolve cannot find a solution and returns empty.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by