フィルターのクリア

Is there any way to convert "*" to ".*"?

1 回表示 (過去 30 日間)
Fernando Pérez Lara
Fernando Pérez Lara 2018 年 11 月 4 日
コメント済み: John D'Errico 2018 年 11 月 4 日
Is there any way to convert this "*" into this ".*"
My output is this
- 1.8420821237718587592979702094453*x^3 + 3.2914765235937450960079786455026*x^2 - 0.44362298592685589504469589883229*x + 0.023160255314885146854519959447316
Thanks!

採用された回答

John D'Errico
John D'Errico 2018 年 11 月 4 日
編集済み: John D'Errico 2018 年 11 月 4 日
Why do you think you need to do so?
In the symbolic expression you refer to, all of the * operators are multiplying a scalar numeric constant times x to some power. This is automatically done by the * operator.
It would have been arguably more important to convert those ^ to .^ operators, since ^ does not trivially do what you may be asking in vectorized form.
So, suppose I have the symbolic expression...
vpa(F)
ans =
- 1.8420821237718587592979702094453*x^3 + 3.2914765235937450960079786455026*x^2 - 0.44362298592685589504469589883229*x + 0.023160255314885146854519959447316
matlabFunction(F)
ans =
function_handle with value:
@(x)x.*(-4.436229859268559e-1)+x.^2.*3.291476523593745-x.^3.*1.842082123771859+2.316025531488515e-2
As you can see, matlabFunction did what you wanted, I think. So you CAN do what you wanted.
  3 件のコメント
Fernando Pérez Lara
Fernando Pérez Lara 2018 年 11 月 4 日
Working, thank you very much.
John D'Errico
John D'Errico 2018 年 11 月 4 日
It is a feature that I seem to forget too often myself. But then there are many capabilities of MATLAB that are easy to miss, especially in any language that continuously (slowly) changes with time, adding new features as we go.

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

その他の回答 (2 件)

madhan ravi
madhan ravi 2018 年 11 月 4 日
Simple answer is you can't
  8 件のコメント
madhan ravi
madhan ravi 2018 年 11 月 4 日
Anytime :)
John D'Errico
John D'Errico 2018 年 11 月 4 日
help matlabFunction

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


Walter Roberson
Walter Roberson 2018 年 11 月 4 日
If you have a character vector holding the expression then you can use vectorize()
(matlabFunction calls vectorize)

カテゴリ

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