Incorrect argument data type or missing argument in call to function 'sqrt'.
조회 수: 4 (최근 30일)
이전 댓글 표시
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'.
댓글 수: 0
답변 (3개)
VBBV
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.NominalValue+Lg0.NominalValue)./(Lc0.NominalValue*Lg0.NominalValue*Cf0.NominalValue))
댓글 수: 2
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
2023년 6월 20일
clc
Lc0 = ureal('Lc0',4.2e-3,'percent',10)
get(Lc0)
Lg0 = ureal('Lgo',2.5e-3,'percent',30)
get(Lg0)
Cf0 = ureal('Cf0',8e-6,'percent',10)
get(Cf0)
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.
댓글 수: 0
RANGA BHARATH
2023년 6월 20일
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)
Lg0 = ureal('Lgo',2.5e-3,'percent',30)
Cf0 = ureal('Cf0',8e-6,'percent',10)
%% Typecasting
sqrt((double(Lc0) + double(Lg0)) / (double(Lc0) * double(Lg0) * double(Cf0)))
%% Specifying the NominalValue
wr=sqrt((Lc0.NominalValue+Lg0.NominalValue)/(Lc0.NominalValue*Lg0.NominalValue*Cf0.NominalValue))
Links to Documentation:
- Here is the link to the documentation of ureal to know accessing a particular property of the uncertain real parameter: Uncertain real parameter - MATLAB - MathWorks India
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Uncertain Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!