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
 All Forums
 Origin Forum
 Origin Forum
 Need help: Filter values in a matrix

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
muguangde Posted - 08/30/2012 : 2:57:57 PM
Origin Ver. and Service Release (Select Help-->About Origin): 8.5
Operating System: win7

Hi All,

I have a very simple question. I have a 200X200 matrix with element values ranged from 0 to 10, If I want to filter half of them and only get a new matrix with element values>5 and also output the column and row number of the element after filtering.

Is there a quick way to do it please?

Thanks in advance,
muguangde
3   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 08/31/2012 : 10:40:25 AM
Hi muguangde,

Then, probably you need a LabTalk script, or an Origin C program to speed up.
Here is a sample script. Try to see if this runs enough fast, or not.

///////////////////////////////
threshold=5;
if(exist(%H)!=5) {type -b Activate a matrix; Return;};
%M=%H;
Window -t wks;
%W=%H;
Worksheet -a 1;
range r1=[%W]!1;
range r2=[%W]!2;
range r3=[%W]!3;
Window -a %M;
nc=wks.ncols; 
nr=wks.nrows;
kk=0;
break -b Scanning %M;
break -r 1 nc;
Loop(jj,1,nc) {
  break -p jj;
  Loop(ii,1,nr) {
    if(cell(ii,jj)>threshold) {kk++; r1[kk]=jj; r2[kk]=ii; r3[kk]=cell(ii,jj);}
  }
}
break -end;
Window -a %W;
///////////////////////////////
--Hideo Fujii
OriginLab
muguangde Posted - 08/30/2012 : 4:51:46 PM
Hi,Hideo,

Thank you very much for the reply. I followed your method and it is working quite well. Now I have my matrix converted into a worksheet, but I still have one more problem, my matrix is 200X200 in size and 40000 elements.

Is there any quick way filter them in the worksheet and output the column/row number(it must be a long list) please?

Thanks again,
muguangde
Hideo Fujii Posted - 08/30/2012 : 3:51:15 PM
Hi muguangde,

How about the following way?

1) Set the X/Y mapping to column/row index ("Matrix: Set Dimension/Labels" menu) such that the "From" and "To" values for X are 1 and the number of columns, and for Y are 1 and the number of rows. (If you have your own mapping, and don't want to change, you need to make a duplicate matrix.)
Note: You can do this also by the following command:
    mdim x1:=1 x2:=wks.ncols y1:=1 y2:=wks.nrows;
2) Convert the matrix to a worksheet ("Matrix: Convert to Worksheet" menu with "XYZ Columns" in Method option.

3) Using the Worksheet Query, extract the rows which match your condition (C>5).

Hope this works for you.

--Hideo Fujii
OriginLab

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000