Check for missing argument or incorrect argument data type in call to function 'expand'

33 ビュー (過去 30 日間)
Priyanshu
Priyanshu 2023 年 7 月 16 日
回答済み: Ayush 2024 年 10 月 31 日 10:11
After using sym2poly to get the coefficients of a polynomial, I get the following : B = 1.0e+07 * 0.0000 0.0003 0.0103 2.5110 2.6503 -0.0500 Then I am trying to multiply the 1.0e+07 by the vector, so I used expand(B). It gives the following error Check for missing argument or incorrect argument data type in call to function 'expand'. How can I expand that expression anyway?

回答 (2 件)

Ayush
Ayush 2024 年 10 月 31 日 10:11
The expand function in MATLAB is used to expand and simplify symbolic expressions. However, in your case, you have a numeric vector B obtained from sym2poly, which means it contains numeric coefficients rather than symbolic expressions.
To perform the multiplication of the entire vector B by 1.0e+07, you don't need to use expand” function. You can simply multiply the vector by the scalar value directly. Here’s a snippet representing the operation:
format long
B = [0.0000, 0.0003, 0.0103, 2.5110, 2.6503, -0.0500];
multiplied_B = 1.0e+07 * B
multiplied_B = 1×6
1.0e+07 * 0 0.000300000000000 0.010300000000000 2.511000000000000 2.650300000000000 -0.050000000000000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
So, B is your numeric vector and multiplied_B will store the result of multiplying each element of B by 1.0e+07.
Note that there is no need to use expand in this case since you are dealing with numeric values rather than symbolic expressions. Also, "format long" is used to provide both high precision and flexibility in scientific or fixed-point notation.
Hope it helps!

Walter Roberson
Walter Roberson 2024 年 10 月 30 日 16:39
I get the following : B = 1.0e+07 * 0.0000 0.0003 0.0103 2.5110 2.6503 -0.0500
Give the command
format long g
and display the results again.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by