My code answers empty sym 0 by 1, except when the symbol equals zero.

I don't know why a majority of my code says, "Empty sym: 0-by-1", except when x equals zero. I don't know what's wrong.
syms x
y=(x^2)-(x/(x+3))
y = 
y0=solve(x,0)
y0 = 
0
y1=solve(x,1)
y1 = Empty sym: 0-by-1
y2=solve(x,2)
y2 = Empty sym: 0-by-1
y3=solve(x,3)
y3 = Empty sym: 0-by-1
y4=solve(x,4)
y4 = Empty sym: 0-by-1
y5=solve(x,5)
y5 = Empty sym: 0-by-1
y6=solve(x,6)
y6 = Empty sym: 0-by-1
y7=solve(x,7)
y7 = Empty sym: 0-by-1

Réponses (2)

Torsten
Torsten le 17 Fév 2025
Déplacé(e) : Torsten le 17 Fév 2025
I don't know what you mean by "solve(x,7)", e.g.
If you want to insert x = 7 in the expression for y, use
syms x
y=(x^2)-(x/(x+3))
y = 
subs(y,x,7)
ans = 
syms x
y1=solve(x,1)
y1 = Empty sym: 0-by-1
That means to solve the system of simultaneous equations
x == 0
ans = 
1 == 0
ans = logical
0
As it is impossible for 1 to equal 0, there cannot be a solution.
I suspect, by the way, that you want to solve y rather than x.
syms x
y=(x^2)-(x/(x+3))
y = 
solve(y, x)
ans = 
but possibly you want
subs(y, x, 0:7)
ans = 

Catégories

En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by