Sponsored Content
Top Forums UNIX for Dummies Questions & Answers convert matrix to row and columns Post 302324864 by tintin72 on Friday 12th of June 2009 04:46:51 AM
Old 06-12-2009
Data convert matrix to row and columns

Dear Unix Gurus,

I have a sample data set that looks like this

Code:
 
    y1  y2  y3  y4  y5
x1 0.3 0.5 2.3 3.1 5.1
x2 1.2 4.1 3.5 1.7 1.2
x3 3.1 2.1 1.0 4.1 2.1
x4 5.0 4.0 6.0 7.0 1.1

I want to open it up so that I get
Code:
x1 y1 0.3 
x2 y1 1.2 
x3 y1 3.1 
x4 y1 5.0 
x1 y2 0.5
x2 y2 4.1
x3 y2 2.1
x4 y2 4.0
x1 y3 2.3 
x2 y3 3.5
x3 y3 1.0
x4 y3 6.0
x1 y4 3.1
x2 y4 1.7 
x3 y4 4.1 
x4 y4 7.0
x1 y5 5.1
x2 y5 1.2 
x3 y5 2.1 
x4 y5 1.1

I'm stuck. Smilie Can someone help? Thanks a lot.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to convert 2 column data into multiple columns based on a keyword in a row??

Hi Friends I have the following input data in 2 columns. SNo 1 I1 Value I2 Value I3 Value SNo 2 I4 Value I5 Value I6 Value I7 Value SNo 3 I8 Value I9 Value ............... ................ SNo N (1 Reply)
Discussion started by: ks_reddy
1 Replies

2. Shell Programming and Scripting

Convert columns to single row

Hello all I have data like 1 2 3 4 5 I wish my output would be like 1,2,3,4,5 For this i have executed 'BEGIN {FS="\n"; ORS=","} {print $0}' test and got the output as 1,2,3,4,5, I do not want to have , at the end of 5. output should be like (5 Replies)
Discussion started by: vasuarjula
5 Replies

3. Ubuntu

How to convert full data matrix to linearised left data matrix?

Hi all, Is there a way to convert full data matrix to linearised left data matrix? e.g full data matrix Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7 Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245 Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
Discussion started by: evoll
8 Replies

4. Shell Programming and Scripting

Convert columns to row using awk

Hi I need to convert some columns form a html file to rows. I do manage to make it works without help (some proud :) ) For some reason the offline status is not in bold, so I do need to remove the <b> tag from the other field to make this to work. All fields are not needed, so I test and... (5 Replies)
Discussion started by: Jotne
5 Replies

5. UNIX for Dummies Questions & Answers

Convert nxm Matrix into columns of data

Dear Unixers, I'm having some difficulty in converting an n x m data matrix into a dataset of 3 columns and nxm rows. As an example I want to convert this dataset 2 3 4 5 2 0.0 0.0 0.1 0.1 6 -0.3 2.0 0.0 0.3 7 -0.6 -1.1 0.5 0.3 9 -0.9 -4.1 -0.7 0.5 ... (2 Replies)
Discussion started by: tintin72
2 Replies

6. Shell Programming and Scripting

awk to convert table-by-row to matrix table

Hello, I need some help to reformat this table-by-row to matrix? infile: site1 A:o,p,q,r,s,t site1 C:y,u site1 T:v,w site1 -:x,z site2 A:p,r,t,v,w,z site2 C:u,y site2 G:q,s site2 -:o,x site3 A:o,q,s,t,u,z site3 C:y site3 T:v,w,x site3 -:p,routfile: SITE o p q r s t v u w x y... (7 Replies)
Discussion started by: yifangt
7 Replies

7. Shell Programming and Scripting

Convert row to columns start from nth column

Dear All, We have input like this: 161 57 1378 176 1392 262 1444 441 1548 538 1611 670 1684 241 57 1378 208 1393 269 1447 444 1549 538 1610 677 1700 321 ... (4 Replies)
Discussion started by: attila
4 Replies

8. Shell Programming and Scripting

How to convert 2 columns into matrix -awk?

How can i convert two columns in to o and 1 matrix. thnks Input a c1 b c2 c c1 d c3 e c4 output c1 c2 c3 c4 a 1 0 0 0 b 0 1 0 0 c 1 0 0 0 d 0 0 ... (5 Replies)
Discussion started by: quincyjones
5 Replies
FEC(3)							   BSD Library Functions Manual 						    FEC(3)

NAME
fec_new, fec_encode, fec_encode, fec_free -- An erasure code in GF(2^m) SYNOPSIS
#include <fec.h> void * fec_new(int k, int n); void fec_encode(void *code, void *data[], void *dst, int i, int sz); int fec_decode(void *code, void *data[], int i[], int sz); void * fec_free(void *code); DESCRIPTION
This library implements a simple (n,k) erasure code based on Vandermonde matrices. The encoder takes k packets of size sz each, and is able to produce up to n different encoded packets, numbered from 0 to n-1, such that any subset of k of them permits reconstruction of the origi- nal data. The data structures necessary for the encoding/decoding must first be created using calling fec_new() with the desired parameters. The code descriptor returned by the function must be passed to other functions, and destroyed calling fec_free() Allowed values for k and n depend on a compile-time value of GF_BITS and must be k <= n <= 2^GF_BITS. Best performance is achieved with GF_BITS=8, although the code supports also GF_BITS=16. Encoding is done by calling fec_encode() and passing it pointers to the code descriptor, the source and destination data packets, the index of the packet to be produced, and the size of the packet. fec_decode() with pointers to the code, received packets, indexes of received packets, and packet size. Decoding is done in place, possibly shuffling the arrays passed as parameters. Decoding is deterministic as long as the received packets are different. The decoding procedure does some limited testing on this and returns if parameters are invalid. EXAMPLE
#include <fec.h> /* * example of sender code */ void *code ; int n, k ; void *src[] ; void *pkt ; code = new_code (k, n ); for (i = 0 ; i < k ; i++ ) src[i] = .. pointer to i-th source packet .. for (each packet to transmit) { i = ... index of the packet ; fec_encode(code, src, pkt, i, size) ; .. use packet in pkt } fec_free(code) ; /* * example of receiver code */ void *code ; int n, k ; void *data[] ; int *ix[] ; code = new_code (k, n ); for (i = 0 ; i < k ; i++ ) { ... receive a new packet ... data[i] = .. pointer to i-th source packet .. ix[i] = .. index of i-th source packet .. } fec_decode(code, data, ix, size) ; /* * now data[] has pointers to the source packets */ Please direct bug reports to luigi@iet.unipi.it . BSD
July 15, 1998 BSD
All times are GMT -4. The time now is 02:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy