フィルターのクリア

solve equation and return a column vector array which has lower root instead of lower and upper root

1 回表示 (過去 30 日間)
Hi guys,
I have an equation which I want to solve for but i'm trying to make it return a column vector of solutions. Say if the input y is a column vector array i.e. [100,200,300,400,500,600,700] I want the solve function to return a column vector as well. The problem lies with equation which solves for two roots and I was hoping to get the lower root i.e.
sol=solve(eqn==0,y);
sol(1);
However it ruins the 'size' of the matrix and i was wondering if anyone knows how to selectively obtain all the lower roots i.e. sol(1) if the solution has 2 solutions.
Any hints would be appreciated.

採用された回答

Star Strider
Star Strider 2015 年 6 月 28 日
You don’t give enough information to provide a specific solution.
If you are solving for the zeros of a one-variable function, it might be most appropriate to use matlabFunction to create an anonymous function out of ‘eqn’, and then use fzero, fsolve, or a related function to find the roots. Depending on what it returns, you can choose the root you want to keep.
Use a loop to define each element of your [1:7]*100 vector in ‘eqn’, and solve it in each iteration.
  2 件のコメント
sarah
sarah 2015 年 6 月 28 日
Thanks. I'll try that and show the specific solution if i get stuck.
Sorry for that i'll keep that in mind next time i ask a question.
Star Strider
Star Strider 2015 年 6 月 28 日
My pleasure.
No worries — it just makes it easier to provide a specific Answer.
If you get stuck, please post the relevant parts of the code you wrote. If it threw any errors, post the complete red text of any errors it threw. If it ran but didn’t do what you wanted, describe what it did you didn’t want it to, and what it didn’t do that you wanted it to.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by