Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Spaces in matlab filenames and paths

Subject: Spaces in matlab filenames and paths

From: Tom Sweetland

Date: 16 Dec, 2003 14:36:50

Message: 1 of 7

How do i get matlab file operations (fopen, fwrite, etc) to recognize
paths that contain spaces (ie 'c:/My Document/file.csv')

Thanks for your help.

Subject: Spaces in matlab filenames and paths

From: Brett Shoelson

Date: 16 Dec, 2003 14:57:32

Message: 2 of 7


"Tom Sweetland" <tsweetland@arcnc.com> wrote in message
news:eeccc6b.-1@webx.raydaftYaTP...
> How do i get matlab file operations (fopen, fwrite, etc) to recognize
> paths that contain spaces (ie 'c:/My Document/file.csv')
>
> Thanks for your help.

Hi Tom,
On one level, this is an "easy question": use the functional form of the
command, if one exists. For instance:

cd('c:\My Documents') ( rather than cd 'c:\My Documents' )

Similarly, see help notes for save, load, ...

When no functional form exists, the question is trickier, and one in which I
too am interested in having answered. How, for instance, can you do
something like
dos('start winword c:\miscellaneous documents\cover letter.doc')??? Anyone?
Brett

Subject: Spaces in matlab filenames and paths

From: Matthew Carson

Date: 16 Dec, 2003 15:11:44

Message: 3 of 7

Quotes work with Word

dos('start winword "c:\miscellaneous documents\cover letter.doc"')

-Matt
Joe Gibbs Racing

Subject: Spaces in matlab filenames and paths

From: Steven Lord

Date: 16 Dec, 2003 15:18:53

Message: 4 of 7

Brett Shoelson wrote:
> "Tom Sweetland" <tsweetland@arcnc.com> wrote in message
> news:eeccc6b.-1@webx.raydaftYaTP...
>> How do i get matlab file operations (fopen, fwrite, etc) to recognize
>> paths that contain spaces (ie 'c:/My Document/file.csv')
>>
>> Thanks for your help.
>
> Hi Tom,
> On one level, this is an "easy question": use the functional form of
> the command, if one exists. For instance:
>
> cd('c:\My Documents') ( rather than cd 'c:\My Documents' )
>
> Similarly, see help notes for save, load, ...
>
> When no functional form exists, the question is trickier, and one in
> which I too am interested in having answered. How, for instance, can
> you do something like
> dos('start winword c:\miscellaneous documents\cover letter.doc')???
> Anyone? Brett

I'd use this:

winopen('c:\miscellaneous documents\cover letter.doc')

When working with the system, though, you would need to conform to how it
expects to handle spaces in arguments. For instance, on a Windows machine,
this lists the contents of the Temporary Internet Files subdirectory of the
c:\winnt directory:

!dir "c:\winnt\Temporary Internet Files"

If you wanted to use DOS in this case, I suspect that this will do what you
want, Brett:

dos('start winword "c:\miscellaneous documents\cover letter.doc"')

--
Steve Lord
slord@mathworks.com

Subject: Spaces in matlab filenames and paths

From: Brett Shoelson

Date: 16 Dec, 2003 15:35:33

Message: 5 of 7


<Snip good advice on opening files with spaces in their names.>

Great! Thanks, Matt and Steve. I wasn't aware of the winopen command, and
didn't think about double quotes.
Brett

Subject: Spaces in matlab filenames and paths

From: Scott Seidman

Date: 16 Dec, 2003 20:54:31

Message: 6 of 7

"Brett Shoelson" <shoelson@helix.nih.gov> wrote in
news:NsJDb.417$Er.31789@mencken.net.nih.gov:

>
> "Tom Sweetland" <tsweetland@arcnc.com> wrote in message
> news:eeccc6b.-1@webx.raydaftYaTP...
>> How do i get matlab file operations (fopen, fwrite, etc) to recognize
>> paths that contain spaces (ie 'c:/My Document/file.csv')
>>
>> Thanks for your help.
>
> Hi Tom,
> On one level, this is an "easy question": use the functional form of
> the command, if one exists. For instance:
>
> cd('c:\My Documents') ( rather than cd 'c:\My Documents' )
>
> Similarly, see help notes for save, load, ...
>
> When no functional form exists, the question is trickier, and one in
> which I too am interested in having answered. How, for instance, can
> you do something like
> dos('start winword c:\miscellaneous documents\cover letter.doc')???
> Anyone? Brett
>
>

Why does
>>cd 'c:\program files'
work for me??

I know it shouldn't, yet it does.

Scott

Subject: Spaces in matlab filenames and paths

From: Lars Gregersen

Date: 28 Dec, 2003 11:55:30

Message: 7 of 7

On 16 Dec 2003 20:54:31 GMT, Scott Seidman
<namdiesttocs@mindspring.com> wrote:

>Why does
>>>cd 'c:\program files'
>work for me??
>
>I know it shouldn't, yet it does.

Why do think it shouldn't work? Just because a feature is undocumented
it is can still work ;-)

You can even do
  cd c:\program' files'
if you like.

  Lars

Lars Gregersen
COMSOL A/S
http://www.comsol.dk

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us