SteveMyres Posted April 7, 2013 Share Posted April 7, 2013 I needed to process a 2D array column-wise, but the relevant functions only worked row-wise. So I could transpose() the array, use the row-wise functions, then transpose() it back, but transpose() only works on 1D arrays. This is an equivalent for 2D arrays: function pivot (string source)private string destfor(private idx = 0, idx < NumCols(source), idx++)dest[idx] = Transpose(source[][idx], 1)endforreturn dest[/CODE] Link to comment Share on other sites More sharing options...
AzeoTech Posted April 7, 2013 Share Posted April 7, 2013 Which functions did you want to use? Some, like mean() have several forms. Link to comment Share on other sites More sharing options...
SteveMyres Posted April 7, 2013 Author Share Posted April 7, 2013 I wanted to step through the array, deleting certain columns. I would have needed a column-wise version of RemoveAt(). Link to comment Share on other sites More sharing options...
AzeoTech Posted April 7, 2013 Share Posted April 7, 2013 See your other post. A key point of that post is to avoid using loops in script when you can do things using array subsetting. http://www.azeotech.com/board/index.php?/topic/5110-myarrayremoveat-for-columns/page__p__18216#entry18216 Link to comment Share on other sites More sharing options...
SteveMyres Posted April 7, 2013 Author Share Posted April 7, 2013 I had to step through in order to examine each column anyway, to see which ones needed deleting, but there was only one iteration per column, so for this particular app that was about as good as it was going to get. Oddly I did try MyNewArray[][jdx] = MyOldArray[][idx] (as well as MyNewArray[][jdx] = transpopse(MyOldArray[][idx], 1)), copying across just the columns I wanted to keep, but the assignment didn't seem to work for some reason. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.