[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: save function
From: |
Mike Miller |
Subject: |
Re: save function |
Date: |
Tue, 8 Mar 2005 11:04:36 -0600 (CST) |
On Tue, 8 Mar 2005, John W. Eaton wrote:
On 6-Mar-2005, Mike Miller <address@hidden> wrote:
| That is a reason to have the feature, but it is not a reason to impose it
| on all users for every data file they save. We often create data files in
| octave to be imported into other programs. It would be very nice if we
| could save in ascii format without the header lines. Something like this
| would do:
|
| `-ascii2'
| save the data as plain text without Octave header information
|
| Haven't we had a lot of questions/complaints that would be resolved by the
| addition of this feature?
|
| Maybe this would work only for 2-d arrays (matrices), but that is often
| the sort of thing we are trying to save: Table data where rows are
| records and columns are fields. Octave save -ascii does what we want
| except that it has those extra initial lines that must be removed by some
| external program before we can use the data.
Sorry, I didn't see this message before I sent my previous reply.
I don't think we want -ascii2 to mean "do the Matlab-compatible -ascii
thing" because it just trades one incompatibility for another. If we
want compatibility, then we have to make Octave's "save -ascii" do what
Matlab's does. That includes saving character strings as numeric data
and allowing multiple values to be stored in a single file (with no
header information that gives you a clue about what variables are where
-- I guess when saving the entire workspace, the variables are stored in
alphabetical order?) and so on. We can still keep Octave's old -ascii
behavior, but we will need rename the option. As I noted in my previous
message, this is likely to cause some pain. How can we minimize it?
I guess we need to hear from some of the people who would find the change
painful. It wouldn't affect me much.
Regarding MATLAB compatibility - I think MATLAB's "save -ascii" behavior
is not so nice. I wonder if people really use it to save multiple
variables in a single file. I also don't like the way MATLAB stores
values like this...
1.0000000e+00 2.0000000e+00 3.0000000e+00
...instead of like this:
1 2 3
The former wastes a lot of space, but the MATLAB idea is to align output
in columns like this:
1.0000000e+000 Inf NaN 1.3700000e+201
8.1797434e+006 3.4197062e+006
6.6022756e+006 2.8972590e+006
-3.0461737e+006 -3.0276440e+006 -3.7837300e+006 -4.9655245e+006
-1.8965375e+006 -5.4167385e+006 -8.6001160e+006 -8.9976918e+006
-1.9343116e+006 -1.5087298e+006 -8.5365513e+006 -8.2162916e+006
-6.8222322e+006 -6.9789848e+006 -5.9356291e+006 -6.4491038e+006
9.8000000e+001 1.1100000e+002 9.8000000e+001
1.0600000e+002 1.1100000e+002 1.0100000e+002
1.1600000e+002 1.1100000e+002 1.0900000e+002
1.0600000e+002 9.7000000e+001 1.1000000e+002
That is MATLAB "save -ascii" output for four variables. The first is 1x4,
the second is 2x2, the third is 4x4 and the last is a 4x3 string matrix:
x=[1 Inf NaN 13.7*10^200];
x2=10000000*rand(2);
x3=-10000000*rand(4);
x4=['bob';'joe';'tom';'jan'];
save -ascii c:\x4.txt x x2 x3 x4
The translation of strings to numbers is probably not what people want,
but it gets worse. Here's how MATLAB (v 5.2 anyway) handles complex
numbers:
# e=eig(rand(3))
e =
1.4768
0.1346 + 0.1774i
0.1346 - 0.1774i
# save -ascii c:\e.txt e
This is all it saves:
1.4768417e+000
1.3460833e-001
1.3460833e-001
MATLAB's "save -ascii" simply deletes the imaginary part of the complex
number!
So, I think we'd better proceed very carefully toward compatibility in
this case. It's easy to see why you (John) didn't make Octave's "save
-ascii" compatible with MATLAB's in the first place.
Maybe we should be using "save -matlab -ascii" to turn on MATLAB
compatibility in this case because it is so badly broken.
Regarding my idea to add a -ascii2 option: I think maybe -ascii_noheaders
would be a better name, and I would use that, but I have no use for a
fully MATLAB compatible "save -ascii" now that I know what it does!
Mike
--
Michael B. Miller, Ph.D.
Assistant Professor
Division of Epidemiology and Community Health
and Institute of Human Genetics
University of Minnesota
http://taxa.epi.umn.edu/~mbmiller/
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Re: save function, (continued)
- Re: save function, Mike Miller, 2005/03/09
- Re: save function, Mike Miller, 2005/03/09
- Re: save function, David Bateman, 2005/03/10
- Re: save function, Robert A. Macy, 2005/03/09
- Re: save function, John W. Eaton, 2005/03/09
- Re: save function [take 97], Steve C. Thompson, 2005/03/09
- Re: save function, Jonathan C. Webster, 2005/03/09
- Re: save function, John W. Eaton, 2005/03/09
- Re: save function,
Mike Miller <=
- Re: save function, Mike Miller, 2005/03/08
Re: save function, Thorsten Meyer, 2005/03/09