Jump to content

How does LabVIEW define a 2D array?


Recommended Posts

"Each element in the first dimension of the array corresponds to a channel in the task. Each element in the second dimension of the array corresponds to a sample to write to each channel."

This sentence is from the help document of LabVIEW 8.2 for "DAQmx Write.VI(Digital Output)."

My question is that for a 2D array, is the first dimension of the array the colum or the row?

Thanks a lot.

Link to comment

QUOTE (zorro @ Aug 8 2008, 01:04 PM)

"Each element in the first dimension of the array corresponds to a channel in the task. Each element in the second dimension of the array corresponds to a sample to write to each channel."

This sentence is from the help document of LabVIEW 8.2 for "DAQmx Write.VI(Digital Output)."

My question is that for a 2D array, is the first dimension of the array the colum or the row?

Thanks a lot.

First = row

Second = column

You can get this info by hovering your mouse over the "Index Array".

You'll get the first as "Row Index" and second as "Column Index".

Similarly for a 3D, you'll get the first as "Page index", then "Row Index" and finally "Column Index".

Link to comment

QUOTE (eaolson @ Aug 8 2008, 01:37 PM)

The first index is the row, the second index is the column.

This is a secret English usage trick: We say in mathematics and other places ",Row Column notation." In almost any instance where there is a two dimensional matrix under discussion rows are discussed first, then columns.

Link to comment

QUOTE (mross @ Aug 8 2008, 12:56 PM)

This is a secret English usage trick: We say in mathematics and other places ",Row Column notation." In almost any instance where there is a two dimensional matrix under discussion rows are discussed first, then columns.

And yet almost any time you're talking about an index of pixels for an image, they're in (x,y) coordinates, which is really (col, row). That one bites me almost every time. I've seen different packages use (0,0) for the bottom-left or the upper-left pixel, too.

Link to comment

QUOTE (eaolson @ Aug 11 2008, 04:39 PM)

And yet almost any time you're talking about an index of pixels for an image, they're in (x,y) coordinates, which is really (col, row). That one bites me almost every time. I've seen different packages use (0,0) for the bottom-left or the upper-left pixel, too.

You may talk about them that way, but they're not stored that way.

Even the old BMP format stores a collection of rows to generate a 2D picture.

Try to imagine the old CRT with horizontal and vertical frequencies.....

Shane.

Link to comment

QUOTE (shoneill @ Aug 11 2008, 10:06 AM)

You may talk about them that way, but they're not stored that way.

Even the old BMP format stores a collection of rows to generate a 2D picture.

True, but it seems to me that the API is more important than the internal storage mechanism. You've got:

  • Java's BufferedImage.getRGB(int x, int y)
  • ImageJ's ImagePlus.getPixel(int x, int y)
  • ImageMagick's MagickGetImagePixelColor(... long x,long y, ...)

I wonder if the discrepancies here are due to thinking about arrays in terms of matrices (row, col) vs. Cartesian coordinates (x,y).

Matlab actually does store arrays in column-wise format, for some reason.

Link to comment

QUOTE (eaolson @ Aug 11 2008, 07:50 PM)

True, but it seems to me that the API is more important than the internal storage mechanism. You've got:

  • Java's BufferedImage.getRGB(int x, int y)
  • ImageJ's ImagePlus.getPixel(int x, int y)
  • ImageMagick's MagickGetImagePixelColor(... long x,long y, ...)

I wonder if the discrepancies here are due to thinking about arrays in terms of matrices (row, col) vs. Cartesian coordinates (x,y).

Matlab actually does store arrays in column-wise format, for some reason.

Differentiation between internals and the API is a topic unto itself of course.

I think most people might also illustrate a 1-D structure in the horizontal rather than the vertical so it might be some innate preference hard-wired into our brains.

Shane.

Link to comment

QUOTE (eaolson @ Aug 11 2008, 12:50 PM)

I wonder if the discrepancies here are due to thinking about arrays in terms of matrices (row, col) vs. Cartesian coordinates (x,y).
This is exactly the differentiator. By convention, across every programming language I have ever worked in, it is always (x,y) and it is always (row, col) and these are backwards from each other. Arrays are row,col because of the tight association of arrays with matricies, but graphics APIs are x,y.

Even more exciting -- monitors use x,y, but the origin is at the top left, whereas Cartesian coordinates have the origin at the bottom left. So the Y coordinate is inverted from the usual direction. This is also consistent across every language I've worked in, LV included.

Link to comment

QUOTE (shoneill @ Aug 11 2008, 02:39 PM)

Differentiation between internals and the API is a topic unto itself of course.

I think most people might also illustrate a 1-D structure in the horizontal rather than the vertical so it might be some innate preference hard-wired into our brains.

Shane.

Not me. If you pull a 1d array horizontally you cannot see very many elements before the screen is used up. On this account I usually pull 1d down into columns to see more.

Link to comment

QUOTE (mross @ Aug 11 2008, 09:12 PM)

Not me. If you pull a 1d array horizontally you cannot see very many elements before the screen is used up. On this account I usually pull 1d down into columns to see more.

I meant "most people" in a more general sense i.e. not just LV programmers.....

I think in a pencil-and-paper scenario, more people would draw a horizontal line than a vertical line.

Shane.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.