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:
Matrix to Text File

Subject: Matrix to Text File

From: Silvia

Date: 11 Jun, 2013 09:26:11

Message: 1 of 5

Hi,

I tried to save a matrix as a text file using the following two Matlab commands:
>> myMatrix2 = double(myMatrix);
>> dlmwrite('myFile.txt', myMatrix2);

It gave me the following error:

Error using ==> dlmwrite at 126
Could not open file myFile.txt

I'm running MATLAB R2008a under Wndows 7.

How I can solve this problem.

Thanks
Silvia

Subject: Matrix to Text File

From: dpb

Date: 11 Jun, 2013 11:29:43

Message: 2 of 5

On 6/11/2013 4:26 AM, Silvia wrote:
> Hi,
>
> I tried to save a matrix as a text file using the following two Matlab
> commands:
>>> myMatrix2 = double(myMatrix);
>>> dlmwrite('myFile.txt', myMatrix2);
>
> It gave me the following error:
>
> Error using ==> dlmwrite at 126
> Could not open file myFile.txt
>
> I'm running MATLAB R2008a under Wndows 7.
>
> How I can solve this problem.

Be sure you have write permission on the current directory.

Use 'cd' to see which is the present directory.

--

Subject: Matrix to Text File

From: dpb

Date: 11 Jun, 2013 12:28:33

Message: 3 of 5

On 6/11/2013 6:29 AM, dpb wrote:
...

>> Error using ==> dlmwrite at 126
>> Could not open file myFile.txt
>>
>> I'm running MATLAB R2008a under Wndows 7.
>>
>> How I can solve this problem.
>
> Be sure you have write permission on the current directory.
>
> Use 'cd' to see which is the present directory.

OBTW, you can use the optional output from fopen() to return the system
error message if you try to open a file that can tell you why it fails
for more info than dlmwrite() gives.

[fid,msg]=fopen('myFile.txt','wt');

Look at msg content

doc fopen

--

Subject: Matrix to Text File

From: Silvia

Date: 11 Jun, 2013 16:05:09

Message: 4 of 5

dpb <none@non.net> wrote in message <kp755f$dgi$1@speranza.aioe.org>...
> On 6/11/2013 6:29 AM, dpb wrote:
> ...
>
> >> Error using ==> dlmwrite at 126
> >> Could not open file myFile.txt
> >>
> >> I'm running MATLAB R2008a under Wndows 7.
> >>
> >> How I can solve this problem.
> >
> > Be sure you have write permission on the current directory.
> >
> > Use 'cd' to see which is the present directory.
>
> OBTW, you can use the optional output from fopen() to return the system
> error message if you try to open a file that can tell you why it fails
> for more info than dlmwrite() gives.
>
> [fid,msg]=fopen('myFile.txt','wt');
>
> Look at msg content
>
> doc fopen
>
> --
%%%%%%%%%%%%%%%%%%%%

Yes, you are right. I've checked it. But how I can get permanent permission, because this is the default "work" of the Matlab?

Thanks
Silvia

%%%%%%%%%%%%%%%%%%%%

Subject: Matrix to Text File

From: dpb

Date: 11 Jun, 2013 16:11:43

Message: 5 of 5

On 6/11/2013 11:05 AM, Silvia wrote:
> dpb <none@non.net> wrote in message <kp755f$dgi$1@speranza.aioe.org>...
...

>> > Be sure you have write permission on the current directory.
...

> Yes, you are right. I've checked it. But how I can get permanent
> permission, because this is the default "work" of the Matlab?
...

That'll depend on whether this is a personal machine or on a uni network
or what.

I've not used later versions of Windows to be able to tell you where
they've hidden permissions now; that's a MS question but should be able
to find plenty of information about doing so either in the local Windows
help or if not, online queries.

--

Tags for 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