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

3 ビュー (過去 30 日間)
Michael
Michael 2025 年 2 月 16 日
回答済み: Walter Roberson 2025 年 2 月 17 日
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

回答 (2 件)

Torsten
Torsten 2025 年 2 月 17 日
移動済み: Torsten 2025 年 2 月 17 日
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 2025 年 2 月 17 日
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 = 

カテゴリ

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