error with sqrt in Matlab
Ältere Kommentare anzeigen
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?
Antworten (4)
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)
x = sqrt(five)
8 Kommentare
EDISON TOAPANTA IZA
am 11 Dez. 2020
Théophane Dimier
am 11 Dez. 2020
Why are you using int64? If it is to round the value, you should use round, floor or ceil instead of int64.
EDISON TOAPANTA IZA
am 11 Dez. 2020
If sqrt were defined for int64 variables, your GEH2 would be:
GEH2 = int64(sqrt(69825))
Is that acceptable to you?
GEH2.^2
EDISON TOAPANTA IZA
am 11 Dez. 2020
Steven Lord
am 11 Dez. 2020
Can you show the output of the following command executed immediately before the line where you define FGEH?
whos flujo_sim2 FlujoReal2
I suspect one or both of those variables are int64. If so the results of all that arithmetic is again an int64 array and sqrt is not defined for int64 arrays.
EDISON TOAPANTA IZA
am 14 Dez. 2020
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)
sqrtInt = int64(sqrt(5))
sqrtDouble.^2 - 5 % close to 0
sqrtInt.^2 - 5 % not really close to 0
Théophane Dimier
am 11 Dez. 2020
0 Stimmen
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
am 11 Dez. 2020
0 Stimmen
Cannot take sqrt of int64 data type. Take sqrt of double then round and convert to int64.
ramadurai ramapragasam
am 29 Jul. 2021
0 Stimmen
preprocds = transform(letterds,@scale)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!