- Index
- » Programming
- » Modelica Language
- » Wrong type or wrong number of...
Wrong type or wrong number of arguments to Integer
Wrong type or wrong number of arguments to Integer
Always the same error "Wrong type or wrong number of arguments to Integer(vector[i])."
I just want to compare the elements of a Real vector (e.g. [-1, 0, 1, 4]) to an Integer.
But I cannot convert the element of the vector to an Integer! I would avoid to compare Reals!
My code is simple as the following:
Code:
function findElement
extends Modelica.Icons.Function;
input Integer e "Search for e2";
input Real[:] vector "Vector to search";
output Integer result;
algorithm
result := 0;
for i in 1:size(vector,1) loop
if Integer(vector[i]) == e then
result := i;
break;
end if;
end for;
end findElement;
- DarioMangoni
- 45 Posts
Re: Wrong type or wrong number of arguments to Integer
Wops, I mispelled the name of the function.
Although many other conversion function start with Capital letter (String(enum), Integer(enum), etc...), the one that translates from Integer to Real is
integer(Real num)
instead of
Integer(Real num)
- DarioMangoni
- 45 Posts
- Index
- » Programming
- » Modelica Language
- » Wrong type or wrong number of...