help-octave
[Top][All Lists]
Advanced

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

RE: Joining arrays


From: CLOSE Dave
Subject: RE: Joining arrays
Date: Tue, 23 Jun 2009 17:58:51 -0700

I asked:

> I want to join two arrays to make a bigger array.

Judd Storrs answered:

> I think should [ A B ] work.

Ok, thanks; I missed the space separator. I was using a comma. But, as
you can probably guess, this is just the latest frustration with a more
complex task. Here's an outline of the whole problem.

Given a CSV file with 15 columns, I want to create a new CSV file with
the first column identical to the first column of the existing file and
a single additional column equal to a convolution of one of the other
columns of the existing file. Diagrammatically,

  FileA = Time, H2,H3,H4,..       FileB = Time, Hx
          00:05,01,02,03,..  ==>          00:05,11
          00:10,04,05,06,..               00:10,12
          00:15,07,08,09,..               00:15,13

(The numbers aren't real, just made up for this example. But the first
column is a time of day string, not a simple number. It actually
contains a date as well.)

I can read in FileA with << A = csv2cell ( "FileA" ); >> and extract
just the first column with << T = A ( :, 1 ); >>. I can read it in again
with << B = dlmread ( "FileA", "," ); >> and perform my convolution on
column 2 like this,

  f = # some formula;
  r = rows ( B );
  C1 = conv ( B(2:r,2), f );
  C2 = rot90 ( C1 );

Now I need to join T and C2 to produce a new array, presumably a cell
array which I can write out with cell2csv(). But I also need to add a
heading to the C2 column. When I try << C2 = { "Hx" rot90(C1) }; >>, I
get the aforementioned array of arrays, even using a space rather than a
comma.




reply via email to

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