Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
I have a .vi I am trying to write in Labview for a project that really has me stuck. Basically what I want to be able

to do is calculate distance using pythagoras, given a user selected number of dimensions (up to 20). That means rather

than traditionally just calculating pythagoras using x and y, I now have x, y, z, .... etc.

Currently I am at the stage where I can send an array of integers, where each represents which dimension to use

in calculation. eg 1 is x, 2 is y, 3 is z ... etc.

What I have done is a .vi for just x and y, which I have attatched but as for expanding this for z, alpha, beta,

gamma, delta etc I draw a blank. Any clues?

02-17-2010 04:47 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

to do is calculate distance using pythagoras, given a user selected number of dimensions (up to 20). That means rather

than traditionally just calculating pythagoras using x and y, I now have x, y, z, .... etc.

Currently I am at the stage where I can send an array of integers, where each represents which dimension to use

in calculation. eg 1 is x, 2 is y, 3 is z ... etc.

What I have done is a .vi for just x and y, which I have attatched but as for expanding this for z, alpha, beta,

gamma, delta etc I draw a blank. Any clues?

Solved! Go to Solution.

Highlighted
Options

Solution

Accepted by topic author eword

02-17-2010 07:25 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

LabVIEW will do primitive operations on arrays. For example, if you connect two one-dimensional arrays into the add primitive, it will return an array that contains and element by element addition of the inputs. This makes your problem fairly easy. Instead of indexing individual points, index the entire location vectors of the two points you want to know the distance between. Subtract one from the other to get the differences. Square the resultant vector. Use the Array Sum to sum it, then take the square root. This approach will scale with however many dimensions you want.

Good luck!

This account is no longer active. Contact ShadesOfGray for current posts and information.

Highlighted
Options

02-17-2010 07:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Thanks. Being able to perform operations on the entire array fixed my problem.