The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 How to range a multi-column data to one column?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hearme

China
11 Posts

Posted - 11/19/2003 :  09:21:50 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Some XRD data are in this form:
a b c d e
f g h i j
k l m n o
... ...

In order to redraw the XRD pattern in origin, I need to change these data to the following format,

a
b
c
d
e
f
g
h
i
j
...
Could you please tell me how to do this in origin?
Thanks

Mike Buess

USA
3037 Posts

Posted - 11/19/2003 :  10:44:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is an easy method. It assumes your worksheet contains ncols columns and nrows rows.

1> With worksheet showing select Edit->Convert to Matrix->Direct
2> Select Matrix->Set Dimensions
3> Set Columns=ncols*nrows and Rows=1. OK. (Creates single row)
4> Matrix->Transpose (Converts to single column)
5> Edit->Convert to Worksheet->Direct

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/19/2003 10:44:48 AM
Go to Top of Page

Laurie

USA
404 Posts

Posted - 11/19/2003 :  11:04:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can also write an Origin C function to do this, such as the following:

void hearme_transpose(string strWksName, string strWksName2)
{
Worksheet wks(strWksName);
Dataset ds(strWksName,0);
Dataset ds2(strWksName2,0);
ds2.SetSize(ds.GetSize()*wks.GetNumCols());
int count=0;
for(int i=0;i<ds.GetSize();i++)
{
for(int j=0;j<wks.GetNumCols();j++)
{
ds2[count]=wks.Cell(i,j);
count++;
}
}

}

The function takes 2 arguments: the name of the worksheet that contains the data and the name of the worksheet that will hold the new column of data.

If you need help on how to use this function from the Script Window, once compiled, let me know. You can email me at tech@originlab.com.

OriginLab Technical Support
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/19/2003 :  11:25:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In case you are not using Origin 7 or 7.5 this can also be done in LabTalk. Start with the original ncols by nrows worksheet active...

mat.wksName$=%H;
ncols=wks.ncols; // find number of columns
get col(1) -e nrows; // find number of rows
win -t M; // open matrix window
mat.matName$=%H;
matrix -ps D ncols nrows; // set columns and rows
mat.w2m(); // convert wks to matrix
matrix -ps D ncols*nrows 1; // change matrix to single row
matrix -t; // transpose (change to single column)
win -t D; // open new wks
mat.wksName$=%H;
mat.m2w(); // convert matrix to wks
%M=mat.matName$;
win -c %M; // close matrix window
del %M; // delete its data separately

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/19/2003 11:27:53 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000