Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab path names with spaces... work around?

Tags:

matlab

I have many folder names with spaces in it, ie "red dog" --> "c:\red dog\"

files = dir
str = ['cd ', files(3).name]
eval(str)

The execution returns the error do to the space:

>> eval(str)
Error using cd
Too many input arguments.

What is the work around?... thx

like image 523
jdl Avatar asked Jan 15 '13 22:01

jdl


2 Answers

Do you have a reason for using eval? Try just

cd(files(3).name);
like image 173
Ben Voigt Avatar answered Oct 03 '22 06:10

Ben Voigt


Try using cd(files(3).name) instead of cd files(3).name (this is, call the cd function using brackets).

If for some reason you want to use cd as a command and not as a function (cd myPath instead of cd(myPath)), you have to enclose the string in single quotation marks. This way your example would look like this:

str = ['cd ''', files(3).name '''']
eval(str)
like image 34
Digna Avatar answered Oct 03 '22 06:10

Digna