May 3, 2009 #1 rm2 Mechanical Jun 7, 2005 41 0 0 MX Hello I am indexing information from a xls file, most of it by columns. How can I place conditions to the importing data? i.e. Indexing data from Col1 that is greater than 0 Col 1 3 4 5 0 9 variablex= data ,1) IF >0 ????????????? thanks for your help
Hello I am indexing information from a xls file, most of it by columns. How can I place conditions to the importing data? i.e. Indexing data from Col1 that is greater than 0 Col 1 3 4 5 0 9 variablex= data ,1) IF >0 ????????????? thanks for your help
May 14, 2009 #2 custodes Military May 4, 2009 2 0 0 US This is how I would do it. %this returns the indeces of all nonzero elements of A to elements of X. X=find(A) %this makes a new matrix (column vector) that is as long as X but with the elements in A, which have indeces given by the elements of X B(1:size(X))=A(X) %Just make a function that imports the variable, runs it through this program, and then spits it into the workspace or a .mat file or whatever. Custodes Upvote 0 Downvote
This is how I would do it. %this returns the indeces of all nonzero elements of A to elements of X. X=find(A) %this makes a new matrix (column vector) that is as long as X but with the elements in A, which have indeces given by the elements of X B(1:size(X))=A(X) %Just make a function that imports the variable, runs it through this program, and then spits it into the workspace or a .mat file or whatever. Custodes
Jun 27, 2009 1 #4 SomptingGuy Automotive May 25, 2005 8,922 0 0 GB A simpler method using "logical indexing" is this: A=A(A~=0); No need to use find(). - Steve Upvote 0 Downvote