How do I assign different solutions from a function as different variables?

2 ビュー (過去 30 日間)
Hoang Nam
Hoang Nam 2020 年 9 月 13 日
コメント済み: Hoang Nam 2020 年 9 月 13 日
Sorry for this very basic question, I just start learning Matlab, so I really appreciate any help
Say I have a function x^2 = x
I put in on solve() like this S = solve(x^2==x,x)
It gives me
S =
0
1
but I want to use those solutions as different variables such as x1 and x2. So, how do I make it x1=0 and x2=1?
Thanks for reading my post

採用された回答

BOB MATHEW SYJI
BOB MATHEW SYJI 2020 年 9 月 13 日
Hope this helps.
syms x
S = (solve(x^2==x,x))';
x1=double(S(1));
x2=double(S(2));

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by