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
All

I have a formula node where I have a module which operates on an array. I want to keep the size of the array generic. So I tried keeping the array size as an input*N*, and initialized the array as xdim[N]. It shows an error in my formula. what am i doing wrong ?

**Kudos are the best way to say thanks 🙂**

02-20-2006 09:21 AM

Options

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

I have a formula node where I have a module which operates on an array. I want to keep the size of the array generic. So I tried keeping the array size as an input

Highlighted
Options
As far as I know the formula node syntax doesn't allow a declaration like "float myArray[SIZE]". You have to actually write an integer value and not an identifier. This is described in the documentation. One thing that's not clear from your post is why you need to initialize the array in the formula node. You said you need to operate on an array, so you must be feeding the array into the formula node in the first place. This means you have the array. Are you trying to create a second array?

Corollary: What is it that you're doing that you believe you need a formula node and can't do with pure LabVIEW code?

smercurio_fc

Knight of NI

02-20-2006 10:16 AM - edited 02-20-2006 10:16 AM

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

Corollary: What is it that you're doing that you believe you need a formula node and can't do with pure LabVIEW code?

Message Edited by smercurio_fc on 02-20-2006 10:17 AM

Highlighted
Options

03-16-2010 10:02 AM

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

I had exactly the same issue as Spartan00.

Just for curiosity, I was comparing labview speed in initializing a gaussian array through both the normal graphic code and the formula node.

The formula node proved to be MUCH, MUCH faster.

float m = 0.5, s=0.5, x; int i; float y[1000000]; for(i=0; i<1000000; i++) { x=i*1e-6; y[i]=exp(-pow((x-m),2)/(2*s)); }

Unfortunately, I can't wire the array size as an input.

(By the way, I simply enclosed the formula node in a for loop and let it run 10000 times to get the average execution time. I did the same for the equivalent graphical code and it turned out to be much slower).

Has anybody ever tried to do the same?

Highlighted
Options
I think your formula node was constant folded. Try passing at least one parameter from LV, e.g. m or s.

03-16-2010 10:13 AM

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

Highlighted
Options

03-16-2010 10:24 AM

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

Excellent point dan_u, you are right, thanks.

Now it is sensibly slowed down. Still a bit faster than the G code but the difference is really small now.