error with sqrt in Matlab

57 ビュー (過去 30 日間)
EDISON TOAPANTA IZA
EDISON TOAPANTA IZA 2020 年 12 月 11 日
回答済み: ramadurai ramapragasam 2021 年 7 月 29 日
hi, help please when I put this formula GEH2= sqrt(2*int64((flujo_sim2-FlujoReal2)^2)/int64(flujo_sim2+FlujoReal2)) in matlab, this returns me the following error: Check for missing argument or incorrect argument data type in call to function 'sqrt'.
why does this error give me?

回答 (4 件)

Steven Lord
Steven Lord 2020 年 12 月 11 日
The sqrt function is not defined for variables of the int64 data type. The square root of an integer value is not necessarily itself an integer value. If it were defined, what exactly would you expect x to be in the following code?
five = int64(5)
five = int64 5
x = sqrt(five)
Check for missing argument or incorrect argument data type in call to function 'sqrt'.
  8 件のコメント
EDISON TOAPANTA IZA
EDISON TOAPANTA IZA 2020 年 12 月 14 日
Hi, of course.
flujo_sim2=datapoint2.get('AttValue', 'Vehs(Current, Total, All)'); %give me value the software external (simulation)
FlujoReal2 =(flujo_med233 + flujo_med234 + flujo_med235); %gives me the total field value (real life) obtained from an excel table.
Steven Lord
Steven Lord 2020 年 12 月 14 日
The lines of code you posted doesn't tell me the class of the variables, which is the important information.
But I repeat my previous question. If you have an int64 number that is not a perfect square, would you be okay with getting an answer that when squared does not give you back the original number?
sqrtDouble = sqrt(5)
sqrtDouble = 2.2361
sqrtInt = int64(sqrt(5))
sqrtInt = int64 2
sqrtDouble.^2 - 5 % close to 0
ans = 8.8818e-16
sqrtInt.^2 - 5 % not really close to 0
ans = int64 -1

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


Théophane Dimier
Théophane Dimier 2020 年 12 月 11 日
Hi, sqrt does not accept int64 as input. If you want to round the quantity first, use round, ceil or floor functions instead

David Hill
David Hill 2020 年 12 月 11 日
Cannot take sqrt of int64 data type. Take sqrt of double then round and convert to int64.

ramadurai ramapragasam
ramadurai ramapragasam 2021 年 7 月 29 日
preprocds = transform(letterds,@scale)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by