spearman Posted August 2, 2010 Report Share Posted August 2, 2010 (edited) Hello, I am trying to use Matlab Script node in LabView 9.0 to create a two-dimensional array and access its columns using the colon operator, like so: bar = foo(:,2); However, instead of the entire column, the bar is assigned only first element in that column. I have tried this code in Matlab 2009, and, of course, it works as expected, returning a column vector. Below is a screenshot of the simplified version of my LabView code, along with a reference screenshot of Matlab 2009. I have assigned the data type of foo to a 2-D Array of Real, and bar/baz to 1-D Array of Real. Edited August 2, 2010 by spearman Quote Link to comment
Ton Plomp Posted August 2, 2010 Report Share Posted August 2, 2010 Long shot, what happens if you make bar and baz a 2-d array? It might be that the orientation is off. Ton Quote Link to comment
Saverio Posted August 2, 2010 Report Share Posted August 2, 2010 Ton is correct. You have to set 'bar' and 'baz' to be 2D arrays because of the way LabVIEW populates arrays. LabVIEW has no concept of vectors, so rows and columns are the same with respect to 1D arrays. The alternative is to change your Matlab code to : bar=foo(:,1)'; (i.e., transpose it inside of the script). Then 'bar' and 'baz' can be 1D arrays. Quote Link to comment
spearman Posted August 2, 2010 Author Report Share Posted August 2, 2010 Thank you very much! Both suggestions work, but I think I will stick with Saverio's advice to transpose the vectors. 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.