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

3 views (last 30 days)
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

Answers (2)

Torsten
Torsten on 17 Feb 2025
Moved: Torsten on 17 Feb 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 = 

Walter Roberson
Walter Roberson on 17 Feb 2025
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 = 

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!