Jump to content

Matlab script column indexing works incorrectly


Recommended Posts

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.

post-17951-066730700 1280723896_thumb.jp

Edited by spearman
Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.