Dmitry
Dmitry

Reputation: 1330

How to make Octave interpret function arguments as numbers?

I have this function in a separate file (my_test_func1.m)

function y = my_test_func1 (x)
y = x + 0;
endfunction

the result of it in the command console 49 for 1, 50 for 2 and so on. So I assume Octave takes my input as strings, not as numbers. How to tell it that I want to use numbers?

I run Octave on Windows - "i686-pc-mingw32"

Upvotes: 0

Views: 61

Answers (1)

Dmitry
Dmitry

Reputation: 1330

OK, I figured it out. I should call the function as

my_test_func1(2)

not

my_test_func1 2

In the first case it's a number, in the second - string. Super obvious (and safe).

Upvotes: 1

Related Questions