필터 지우기
필터 지우기

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

조회 수: 4 (최근 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 CenterFile Exchange에서 Uncertain Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by