1

The following mathematics needs to be done, and is very successfully executed when I set the values manually, such as $a1 = 5, $a2 = 9 etc...

$a = [math]::sqrt([math]::pow(($a2-$a7),2)+([math]::pow(($b2+$b7),2)))
$b = [math]::sqrt([math]::pow(($a1-$a7),2)+([math]::pow(($b1+$b7),2)))
$c = [math]::sqrt([math]::pow(($a1-$a2),2)+([math]::pow(($b1-$b2),2)))
$div = 2*[math]::sqrt(([math]::pow($a,2))*([math]::pow($c,2)))
$div_ini = ([math]::pow($a,2))-([math]::pow($b,2))+([math]::pow($c,2))
([math]::acos($div_ini/$div))*180/[math]::pi

But when I try to set the variables in this way: $a1 = Get-Content a1.txt -First 1 Then suddenly it does not work, and just returns NaN.

When I saw this, I checked if the variables even have the numbers set, so I wrote $a1 and yes, the number was there, it's not missing.

1 Answer 1

1

Get-Content returns a string, not a numeric value. Cast it to a decimal, e.g.

$a1 = Get-Content [decimal]a1.txt - First 1

This might be viewed as a repeat of a previous question and answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .