"solve" Function
10 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to use the "solve" function to find a variable, but the other variables in the equation are input as opposed to defined. How do I fix this? Here's to illustrate what I'm trying to do using a simplified equation:
x=input('x = ')
y=input('y = ')
z=solve('x+y=z',z)
2 件のコメント
Walter Roberson
2021 年 12 月 27 日
編集済み: Walter Roberson
2021 年 12 月 27 日
Example:
syms x
y(x) = sin(x) - x^3/27 %this is the code for the function
fplot(y, [-2*pi 2*pi])
採用された回答
Walter Roberson
2011 年 3 月 9 日
Did you solve the license problem? Until you have the software installed and licensed, solve() isn't going to work.
The answer you are looking for is along these lines:
syms x y z
xin = input('x =');
yin = input('y =');
zsol = solve('z-y=x', z);
disp(['z = ' char(zsol)]);
znum = double(subs(zsol, {x, y}, {xin, yin}));
disp(['z = ' num2str(znum)]);
その他の回答 (2 件)
Andrew Newell
2011 年 3 月 7 日
Here is one way:
x=sym(input('x = '))
y=sym(input('y = '))
syms z
z=solve(z-x-y,z)
5 件のコメント
Andrew Newell
2011 年 3 月 8 日
Oh. I assumed that you were actually using the command "solve", which is in the Symbolic Toolbox.
Walter Roberson
2011 年 3 月 8 日
Please check to see whether you are licensed for the symbolic toolbox but perhaps have just not installed it. If you happen to be using the Student Edition than this could be the difficulty.
solve() is part of the symbolic toolbox and requires that toolbox be installed and licensed.
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
