help-octave
[Top][All Lists]
Advanced

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

Re: Importing columns as a matrix


From: Juan Pablo Carbajal
Subject: Re: Importing columns as a matrix
Date: Fri, 2 Jun 2017 01:54:55 +0200

On Fri, Jun 2, 2017 at 12:56 AM, "Niedermayr, Arthur"
<address@hidden> wrote:
> Hello everybody,
>
> I basically want to import with GNU Octave a matrix of numbers.
>
> It consists of 132651 values which equals 51x51x51 (later I want to reshape
> my matrix with
> reshape(Matrix,51,51,51))
>
> The problem is the format of my data file that I want to import:
> it consists of 6 columns like the following example shows:
>
> 1.value      2.value      3.value      4.value    5.value    6.value
> ...
> ...
> ...
> 132649.value 132650.value 132651.value  no-value  no-value   no-value
>
> So the last 3 values of my 6 x 22109 array are empty (6x22109-3=132651). If
> they would be ignored everything would be perfect.
>
> My data-import command is the following:
> my_textfile=load ("-ascii", "6-columns.txt");
>
> But due to the fact that 3 values are missing, I get the following error:
> error: load: 6-columns.txt: inconsistent number of columns near line 22109
>
> Is there a simple workaround for that?
> Every help is really appreciated! Thank you in advance!
>
> Best regards
> Arthur Niedermayr
>
>
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave
>
The simplest hack is to erase the last line of your data and add it
later manually. You could also use dlmread and read all except the
last row or to insert NA in the missing values.

1. first hack
sed '$ d' 6-columns.txt > 6-columns_new.txt

2. hack
x = dlmread ("6-columns.txt", " ", [0 0 22107 5])

dlmread can also put empty value son those missing ones

x = dlmread ("6-columns.txt", " ", "emptyvalue", NA)

the last row of x will be
132649.value 132650.value 132651.value  NA  NA  NA



reply via email to

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