Incorrect argument data type or missing argument in call to function 'sqrt'.

2 ビュー (過去 30 日間)
Amulya
Amulya 2023 年 6 月 20 日
回答済み: RANGA BHARATH 2023 年 6 月 20 日
clc
Lc0 = ureal('Lc0',4.2e-3,'percent',10);
Lg0 = ureal('Lgo',2.5e-3,'percent',30);
Cf0 = ureal('Cf0',8e-6,'percent',10);
wr=sqrt((Lc0+Lg0)/(Lc0*Lg0*Cf0));
gives following error
Check for incorrect argument data type or missing argument in call to function 'sqrt'.

回答 (3 件)

VBBV
VBBV 2023 年 6 月 20 日
clc
Lc0 = ureal('Lc0',4.2e-3,'percent',10)
Uncertain real parameter "Lc0" with nominal value 0.0042 and variability [-10,10]%.
Lg0 = ureal('Lgo',2.5e-3,'percent',30)
Uncertain real parameter "Lgo" with nominal value 0.0025 and variability [-30,30]%.
Cf0 = ureal('Cf0',8e-6,'percent',10)
Uncertain real parameter "Cf0" with nominal value 8e-06 and variability [-10,10]%.
wr=sqrt((Lc0.NominalValue+Lg0.NominalValue)./(Lc0.NominalValue*Lg0.NominalValue*Cf0.NominalValue))
wr = 8.9310e+03
  2 件のコメント
VBBV
VBBV 2023 年 6 月 20 日
From the outputs of ureal function, it is evident that you need to specify a Nominal value to evaluate the expression within sqrt function. From the doc page of ureal function, the nominal value can be accessed similar to a struct variable within the range inputs
VBBV
VBBV 2023 年 6 月 20 日
clc
Lc0 = ureal('Lc0',4.2e-3,'percent',10)
Uncertain real parameter "Lc0" with nominal value 0.0042 and variability [-10,10]%.
get(Lc0)
NominalValue: 0.0042 Mode: 'Percentage' Range: [0.0038 0.0046] PlusMinus: [-4.2000e-04 4.2000e-04] Percentage: [-10.0000 10.0000] AutoSimplify: 'basic' Name: 'Lc0'
Lg0 = ureal('Lgo',2.5e-3,'percent',30)
Uncertain real parameter "Lgo" with nominal value 0.0025 and variability [-30,30]%.
get(Lg0)
NominalValue: 0.0025 Mode: 'Percentage' Range: [0.0018 0.0033] PlusMinus: [-7.5000e-04 7.5000e-04] Percentage: [-30 30] AutoSimplify: 'basic' Name: 'Lgo'
Cf0 = ureal('Cf0',8e-6,'percent',10)
Uncertain real parameter "Cf0" with nominal value 8e-06 and variability [-10,10]%.
get(Cf0)
NominalValue: 8.0000e-06 Mode: 'Percentage' Range: [7.2000e-06 8.8000e-06] PlusMinus: [-8.0000e-07 8.0000e-07] Percentage: [-10 10] AutoSimplify: 'basic' Name: 'Cf0'

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


Vishnu Vardhan
Vishnu Vardhan 2023 年 6 月 20 日
Hi Amulya,
In this case "sqrt" function is not accepting ureal objects. So instead, try it by changing into double precession scalar.
Here is the sample code:
clc;
Lc0 = ureal('Lc0',4.2e-3,'percent',10);
Lg0 = ureal('Lgo',2.5e-3,'percent',30);
Cf0 = ureal('Cf0',8e-6,'percent',10);
x = (double(Lc0) + double(Lg0)) / (double(Lc0) * double(Lg0) * double(Cf0));
wr = sqrt(x);
Also, note that this error can occur even if the input is negative.

RANGA BHARATH
RANGA BHARATH 2023 年 6 月 20 日
Hi @Amulya. Here is the solution and code for your question.
Question: Incorrect argument data type or missing argument in call to function 'sqrt'.
Solution:
If you go inside the ureal variables you have created, there are some properties associated with the uncertian real parameters.
And there is a property called NominalValue. It has a 'numerical value' and data type associated with it is 'double'.
So, it is evident that instead of passing the whole uncertain real parameter into the sqrt function, you can pass only the NominalValue or you can also typecast the parameter into double.
Code:
clc
Lc0 = ureal('Lc0',4.2e-3,'percent',10)
Uncertain real parameter "Lc0" with nominal value 0.0042 and variability [-10,10]%.
Lg0 = ureal('Lgo',2.5e-3,'percent',30)
Uncertain real parameter "Lgo" with nominal value 0.0025 and variability [-30,30]%.
Cf0 = ureal('Cf0',8e-6,'percent',10)
Uncertain real parameter "Cf0" with nominal value 8e-06 and variability [-10,10]%.
%% Typecasting
sqrt((double(Lc0) + double(Lg0)) / (double(Lc0) * double(Lg0) * double(Cf0)))
ans = 8.9310e+03
%% Specifying the NominalValue
wr=sqrt((Lc0.NominalValue+Lg0.NominalValue)/(Lc0.NominalValue*Lg0.NominalValue*Cf0.NominalValue))
wr = 8.9310e+03
Links to Documentation:

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by