# How can i collect number without using eval function ?

3 views (last 30 days)
ahmet ozdemir on 2 May 2016
Commented: ahmet ozdemir on 2 May 2016
I try to use int2str and num2str which didnot compute the problem. However, it computed ans = 51 43 50 If I give 3+2, it should compute 5 and show the screen which one can be defined ? What is something? Like example:
result=something(Number)
ahmet ozdemir on 2 May 2016
Thanks it works for plus but i want to work it for minus

CS Researcher on 2 May 2016
Edited: CS Researcher on 2 May 2016
You can try something like this:
in = input('Please enter a number:','s');
s = strsplit(in,'+');
result = sum(str2double(s));
ahmet ozdemir on 2 May 2016
Thanks for the answer. I fixed it for my needs and I accepted your solution.

Stephen23 on 2 May 2016
Edited: Stephen23 on 2 May 2016
The safest and most versatile:
num = str2double(input('Please enter a number:','s'));

CS Researcher on 2 May 2016
You mean something like this:
eval(['result = ' Number])
CS Researcher on 2 May 2016
Oh I am sorry. I misread the title.

### Categories

Find more on Matrix Indexing in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by