Effacer les filtres
Effacer les filtres

Error using symengine, Either base or exponent must be a scalar.

2 vues (au cours des 30 derniers jours)
N/A
N/A le 6 Déc 2020
I keep getting this error and don't know how to fix it. Code is below
Error is:
"Error using symengine
Either base or exponent must be a scalar."
syms x y
r = [3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7];
for i = 1:9
eq1 = (x+1)^2 + (y+1)^2 - r(i).^2;
eq2 = (3*x)+2-y;
[x,y] = vpasolve(eq1,[x,y], eq2,[x,y]);
disp(x)
disp(y)
end

Réponse acceptée

Ameer Hamza
Ameer Hamza le 6 Déc 2020
You are overwriting x and y inside the for-loop. The syntax for vpsaolve() is also incorrect.
syms x y
r = [3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7];
for i = 1:9
eq1 = (x+1)^2 + (y+1)^2 - r(i).^2;
eq2 = (3*x)+2-y;
[x_sol,y_sol] = vpasolve([eq1 eq2], [x,y]);
disp(x_sol)
disp(y_sol)
end

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by