Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: dlmwrite help!

Subject: dlmwrite help!

From: lauren_g

Date: 08 May, 2008 14:38:01

Message: 1 of 3

Hi,

I am a matlab novice so please excuse me if my question is silly!

I have a variable I am trying to save as an ASCII. The variable is double precision and each case only takes one of two values. I initially created this variable with each case taking either the value of '0' or '255' (for imagery purposes). I saved it using the following command which worked fine:

dlmwrite('name.asc',E,'delimiter','\t','precision','%.0f')

However, the program I wish to import the ASCII into needs the values to be between 0 and 9 (the actual values do not matter, so long as they are single digits). When I have tried creating the variable so all cases have single digit values (e.g. all '0' or '1', or all '8' and '9') and saved this using the same command as above the ASCII created does not contain any numeric values - just boxes!

Does anyone know why this is?

many thanks

Lauren

Subject: Re: dlmwrite help!

From: dpb

Date: 08 May, 2008 18:01:31

Message: 2 of 3

lauren_g wrote:
...
> I have a variable I am trying to save as an ASCII. The variable is
> double precision and each case only takes one of two values. I
> initially created this variable with each case taking either the
> value of '0' or '255' (for imagery purposes). I saved it using the
> following command which worked fine: >
> dlmwrite('name.asc',E,'delimiter','\t','precision','%.0f')
>
> However, the program I wish to import the ASCII into needs the values
> to be between 0 and 9 (the actual values do not matter, so long as they
> are single digits). When I have tried creating the variable so all cases
> have single digit values (e.g. all '0' or '1', or all '8' and '9') and
> saved this using the same command as above the ASCII created does not
> contain any numeric values - just boxes!
...

W/O specific code to look at, not precisely, no.

But, the following worked fine for me...

 >> x = rand(10,1) % get some arbitrary data
x =
     0.0153
     0.7468
     0.4451
     0.9318
     0.4660
     0.4186
     0.8462
     0.5252
     0.2026
     0.6721
 >> x(x>0.5)=1; x(x<=0.5)=0 % make it bi-valued
x =
      0
      1
      0
      1
      0
      0
      1
      1
      0
      1
 >> dlmwrite('test.dat',x, '\t') % output it
 >> type 'test.dat' % check it's what wanted
0
1
0
1
0
0
1
1
0
1

I'm stuck in a time-warp w/ Matlab R12 so don't have the alternate
optional arguments to dlmwrite later versions have, but you don't need
them for this purpose anyway.

--

 >>

Subject: Re: dlmwrite help!

From: Barry Williams

Date: 08 May, 2008 19:00:25

Message: 3 of 3

I'm not sure that I've got the answer to your question,
but here's a bit more info that may make the problem
murkier.

How are you looking at the file you create? When I open
it in Notepad, all I see are boxes. When I save to
name.txt (with everything else left the same as you wrote
it) and either type name.txt in MatLab or open in Excel, I
see the single integers values that I have wrriten to
name.txt.

Barry

lauren_g <lgxlg1@nottingham.ac.uk> wrote in message
<21483080.1210257689268.JavaMail.jakarta@nitrogen.mathforum
.org>...
> Hi,
>
> I am a matlab novice so please excuse me if my question
is silly!
>
> I have a variable I am trying to save as an ASCII. The
variable is double precision and each case only takes one
of two values. I initially created this variable with
each case taking either the value of '0' or '255' (for
imagery purposes). I saved it using the following command
which worked fine:
>
> dlmwrite
('name.asc',E,'delimiter','\t','precision','%.0f')
>
> However, the program I wish to import the ASCII into
needs the values to be between 0 and 9 (the actual values
do not matter, so long as they are single digits). When I
have tried creating the variable so all cases have single
digit values (e.g. all '0' or '1', or all '8' and '9') and
saved this using the same command as above the ASCII
created does not contain any numeric values - just boxes!
>
> Does anyone know why this is?
>
> many thanks
>
> Lauren

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics