Function converts numbers from command line to ASCII value

Hey guys,
I have a Problem with my input. As soon as I input a number into any functio e.g. 0 it is convertet to the value 48.
This means if I want to run this function on the number 0:
function test(x)
fprintf ('Value: %2.2d \n', x)
end
If I was to enter test 0 into my command line the answer would be 48
And long numbers become just a vector of their ASCII values. Anybody got a clue to why this happens?

 Accepted Answer

You're calling your function in command form.
test 12345
This is equivalent to the following function form:
test('12345')
See this documentation page for more information about command and function form. If you want to pass the number 12345 into test, call it using function form.
test(12345)

1 Comment

Thank you kind Sir this helps a lot. Silly how such a simple thing can drive you crazy...

Sign in to comment.

More Answers (0)

Categories

Asked:

on 9 May 2019

Commented:

on 9 May 2019

Community Treasure Hunt

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

Start Hunting!