GregSands Posted November 4, 2008 Report Share Posted November 4, 2008 It would be helpful to be able to choose which array index to automatically access in a For-loop. It's not too hard to handle for a 2-D array (by transposing beforehand), but it becomes more cumbersome for a 3-D array. I suggest a modification like the following, where all methods give the same result. It may not be straight-forward to allow programmatic access of the array index - if so, it would be sufficient to have a popup menu to choose which index is used, and some visual indication of the usage, as in the lowest example. The same method could also be used to determine how an array is built out of a For-loop. Quote Link to comment
Biometrology Posted November 5, 2008 Report Share Posted November 5, 2008 This is a great idea - I have been having exactly this problem recently, working with 3D arrays. An alternative would be a more powerful transposition function, something like the permute function in MATLAB, where you can freely re-order the dimensions of an N-D array. Then you could simply re-order the dimensions before/after the for-loop. And while we're at it, how about something like the MATLAB squeeze command, which removes "singleton" dimensions, i.e. dimensions with size 1? Alex Quote Link to comment
silmaril Posted November 6, 2008 Report Share Posted November 6, 2008 QUOTE (GregSands @ Nov 3 2008, 10:13 PM) It would be helpful to be able to choose which array index to automatically access in a For-loop. Yes! That's one thing that would really improve programming in LV. It would also improve readability of the code a lot. :thumbup: QUOTE (GregSands @ Nov 3 2008, 10:13 PM) It may not be straight-forward to allow programmatic access of the array index - if so, it would be sufficient to have a popup menu to choose which index is used, and some visual indication of the usage, as in the lowest example. The edit-time-configuration would enable the compiler to optimize this code even further to get a bit more performance out of this. In most algorithms a runtime-decision which dimension is to be indexed is not necessary. Still there might be some occasions where a programmer would like to decide at runtime, which dimension to auto-index. So this feature would be a "nice to have" from my perspective. Quote Link to comment
OlivierL Posted November 6, 2008 Report Share Posted November 6, 2008 I agree with you guys that is would be a really nice feature to have for multiple dimension. Also, I like the idea of the permute function and it should exist in LV. In the mean time, I can share this VI I wrote some time ago to "Transpose" a 3D array. Its input is a 3D array of double and you specify which dimension remains unchanged. Olivier Quote Link to comment
Yair Posted November 8, 2008 Report Share Posted November 8, 2008 If you want NI to see this, you should also send them a message using their product suggestion center (and add a link to this thread). Quote Link to comment
Biometrology Posted November 8, 2008 Report Share Posted November 8, 2008 QUOTE (OlivierL @ Nov 5 2008, 05:39 PM) I agree with you guys that is would be a really nice feature to have for multiple dimension. Also, I like the idea of the permute function and it should exist in LV. In the mean time, I can share this VI I wrote some time ago to "Transpose" a 3D array. Its input is a 3D array of double and you specify which dimension remains unchanged.Olivier Very neat Olivier - thanks! :thumbup: Alex Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.