help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dlmwrite


From: Mon
Subject: Re: dlmwrite
Date: Tue, 28 Jun 2011 04:29:45 -0700 (PDT)

Susanne Nieß wrote:
> 
> Am 27.06.2011 16:02, schrieb Carnë Draug:
>> On 27 June 2011 14:41, Susanne Nieß<address@hidden>  wrote:
>>>>>>> I have a problem with dlmwrite.
>>>>>>> The code attached in bam.m  works fine on matlab producing a normal
>>>>>>> matrix
>>>>>>> file. In octave, however, it produced the file qjbx0203 that I also
>>>>>>> attached
>>>>>>> with a "g" following every number. Octave itself is not able to read
>>>>>>> this
>>>>>>> crazy file. This is a real problem for me because I need such files
>>>>>>> and
>>>>>>> have
>>>>>>> only limited possibilities to make them on matlab. Could you please
>>>>>>> help
>>>>>>> me?
>>>>>>
>>>>>> I believe you forgot to attach the file. Try using pastebin.com
>>>>>> instead of attaching files.
>>>>>>
>>>>> Sorry. Here it is:
>>>>>
>>>>> bam.m:
>>>>> a=load('qjbx1203');
>>>>> a=spconvert(a);
>>>>> b=load('qjbx013');
>>>>> b=spconvert(b);
>>>>> c=a*b;
>>>>> [q1,q2,q3]=find(c);
>>>>> q=[q1 q2 q3];
>>>>> dlmwrite('qjbx0203',q,'delimiter',' ','precision',20);
>>>>> clear;
>>>>>
>>>>> qjbx0203:
>>>>> 1g 1g 6g
>>>>> 2g 2g 2g
>>>>> 3g 2g 2g
>>>>> 4g 3g 2g
>>>>
>>>> You forgot to also reply to the mailing-list. It's better to keep
>>>> conversations there so that everyone can help. Also, you didn't attach
>>>> the files with the original matrix (qjbx1203 and qjbx013).
>>>>
>>>> Anyway, I can read the file generated with dlmwrite, no problem, with
>>>> dlmread. Try:
>>>>
>>>> dlmread('qjbx0203')
>>>>
>>>> You could use the command 'save' to save the matrix into a file as
>>>> well.
>>>>
>>> Thank you for your advice. Now I have an even simpler example:
>>>
>>> bam.m:
>>> q=[1 2 3; 4 5 6];
>>> dlmwrite('testcsv',q,'delimiter',' ','precision',20);
>>> clear;
>>>
>>> testcsv:
>>> 1g 2g 3g
>>> 4g 5g 6g
>>>
>>> If I use the command "save" this changes the format, I want it as a csv
>>> to
>>> leave it compatible with something else. Up to now, I tried to read
>>> files
>>> with "load". Even if I can read those files with dlmread, the additional
>>> "g"
>>> after each number will cost a lot of disk space so the best thing would
>>> still be to eliminate it. There was something about this on the bug
>>> tracker
>>> under bug #29870 but I could not use the solution because the mentioned
>>> file
>>> does not exist on my system. Can you help my?
>>
>> I don't know what that g stands for. But it disappears if you drop the
>> precision=20 option
>>
>> dlmwrite('testcsv',q,'delimiter',' ')
>>
>> Also, there's others formats that you can use with save. See 'help save'
>>
>> Carnë
> 
> Unluckily, the precision is exactly what I need most so I cannot drop 
> it. Save has a lot of formats but I did not find csv. Now I heard that 
> the bug is fixed in the current version so I will install it as soon as 
> I can. Thank you for your efforts to help me.
> 
> 



Unless I misunderstand, the following worked for me.

q=rand(3,3);
dlmwrite('testcsv',q,'delimiter',',','precision','%25.20f')

testcsv:
   0.47911011736185199483,   0.85289670467855605018,  
0.26136768333150944832
   0.80173200925784315896,   0.69342253405720177817,  
0.23661633605614978970
   0.42908395747214428395,   0.02090554059511655696,  
0.32975726448227254961

Regards,
Mon


--
View this message in context: 
http://octave.1599824.n4.nabble.com/dlmwrite-tp3625124p3630075.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]