Is it possible to use 'solve' on a vector of functions?

3 ビュー (過去 30 日間)
Harshvardhan
Harshvardhan 2012 年 11 月 6 日
Is it possible to use 'solve' function on a column/row vector of functions where each row/column is a function of just one variable?
syms t
funcVec = [3*t+2; 5t-3]
solve(funcVec)
For example, running the above lines of code should give me a vector
[-2/3; 3/5].

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 11 月 7 日
No.
You can use
arrayfun(@solve, funcVec)
Or you can use the symbolic map() function. Note that map() is not exposed at the MATLAB level, so you would need evalin() or feval()
  8 件のコメント
Harshvardhan
Harshvardhan 2012 年 11 月 8 日
Walter. That's just awesome.
But, you are right. arrayfun() is just another way of writing a 'for' loop. As a matter of fact, arrayfun() saved me only a few milliseconds and nothing more. I think it's better I stop pursuing vector functionality for symbolic math functions like 'subs' and 'solve' as I understand that MATLAB calls altogether a different engine, to solve such problems, which I think doesn't possess the speed.
Walter Roberson
Walter Roberson 2012 年 11 月 8 日
Yup. You would probably get better speed by evalin(symengine, ...) or feval(symengine, ...) some code that did the work for you all at the MuPAD level, such as by using MuPAD's map() . At the very least that would remove the overhead of talking to the symbolic engine for each operation.

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

カテゴリ

Help Center および File ExchangeUtilities for the Solver についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by