help-octave
[Top][All Lists]
Advanced

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

Re: save both dates and numeric data


From: Jaroslav Hajek
Subject: Re: save both dates and numeric data
Date: Mon, 12 Apr 2010 11:31:18 +0200

On Mon, Apr 12, 2010 at 11:11 AM, abigi <address@hidden> wrote:
>
> Dear Octave forum,
>
>  I am quite a beginner in Octave. I am using Octave 3.0.5 on a x86_64 pc
> linux. I have quite a few numeric data (measurement) which I would need to
> save into a text file according to the following structure of:
>
> 1st column -> dates
> 2nd : 130th colums -> numeric data
>
> I had more than a look to datestr, save, fprintf but I had troubles with
>
>  - creating a matrix or something alike with that structure (1 column of
> date/character type data, other cols numeric data), so that I could save
> straightly. I am doubting that is possible to have this kind of data...
> something like a "dataframe" in R
>
>  - to generate a sequence of dates I have used strvcat + datestr, resulting
> in a character vector: is that a good way to solve this issue?
>

Sure, why not?

> - I have tried with merging everything in a string matrix, but then it was
> getting even messier...
>
> Any suggestion is welcome, thanks,
>
>  Alessandro
>

You can handle tasks like this and much more with fprintf.
Do something like this (not tested):

dates = # NxK character matrix of dates
numbers = # Nx129 numeric matrix of your numeric data

## prepare format of a single row
format = ["%s", repmat(" %f", 1, 129), "\n"];

## prepare data sequentially, as it needs to be printed
seq_data(1, :) = cellstr (dates);
seq_data(2,:) = num2cell (numbers, 2);

fprintf (fid, format, seq_data{:});

hth


-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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