Problem 2368. I want eval
A valid MATLAB statement containing a definition of a vector is passed as a string S. Determine the length of the vector.
Input: S='vec=1:10;'; Output=10
Explanation: if you execute eval(S), a vector vec of length 10 will be generated. Similarly,
Input: S='a=[1 2 3 4 5];' Output=5
Input: S='a=ones(1,10);'; Output=10
Input: S='a=[];'; Output=0;
Solution Stats
Problem Comments
-
2 Comments
J.R.! Menzinger
on 17 Jun 2014
The length of an empty array is 0 not []. ;-)
rifat
on 17 Jun 2014
Sorry for that.. fixed it.. :)
Solution Comments
Show commentsProblem Recent Solvers25
Suggested Problems
-
Remove the small words from a list of words.
1540 Solvers
-
420 Solvers
-
Make a random, non-repeating vector.
10364 Solvers
-
515 Solvers
-
poll: would you like the regexp (?@cmd) functionality to be banned in Cody?
181 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!