Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Xavier Croes
il 12 Mar 2020
Commentato: Star Strider
il 12 Mar 2020
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
0 Commenti
Risposta accettata
Star Strider
il 12 Mar 2020
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.
2 Commenti
Più risposte (1)
Walter Roberson
il 12 Mar 2020
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.
Vedere anche
Categorie
Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!