LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Addition

Hi,How can I make save numbers using labview without using event structure.I have done this using local variables and clusters but its not correct.

Can you guide me to making a counter.

I have an idae in C++;

 

 (for example this simple code to calculate the average of an elements of an array of variable elements)

#include <iostream>

using namespace std;

int main()

{

int n;

new double *A[n];

int counter =0;

cout<<""Welcome to the program!!\nPlease enter the number of elements of the array"<<endl;

cin>>n;

cout<<"Please enter the elements of the array"<<endl;

for(int i=0;i<n;i++)

{cin>>A[i];

counter++;

}

double sum=0;

for(int =0;i++;i<n)

{

sum=sum+A[i];

}

double average=sum/counter;

cout<<"The average of the elements of the array of size"<<n<<"is    "<<average<<endl;

return 0;

}

 

Here the counter is equal to n   (but I hope you have understood my point)

 

Thank you in advancedSmiley Happy

0 Kudos
Message 1 of 8
(3,601 Views)

Wall Ham wrote:

Hi,How can I make save numbers using labview without using event structure.I have done this using local variables and clusters but its not correct.


To take the average of the elements in an array, all you need is the "mean". (There is also a point-by-point version.)

 

(It is not really clear what you did with clusters and locals. If you want us to give code advice, please attach the code attempts and we might be able to erase some misconceptions about dataflow ;))

0 Kudos
Message 2 of 8
(3,596 Views)

I am sorry to mislead you altenbash but I posted the C++ code to show that in C++ I am able to increment the value of the counter easily even though there is a variable "n".

How caN I make a counter using labview indicating the number of turns (parallel to the incrementation of the counter in C++).

Can you show me a simple code(of the counter not the solution) just to fix it on my code(to learn and to understand and not to copy and misuse)

ThanksSmiley Tongue

Sorry to have wasted you're time

0 Kudos
Message 3 of 8
(3,586 Views)

Keep the counter and the sum in a shift register (or feedback node) each. Here's a draft:

 

 

What is your LabVIEW version?

Message Edited by altenbach on 12-12-2009 12:50 PM
Message 4 of 8
(3,582 Views)

 

My version is 2009 evaluation

0 Kudos
Message 5 of 8
(3,574 Views)

How can I create an if clause [in C++](not using the for loop once)

Should LabView contain an if clause?Smiley Wink

0 Kudos
Message 6 of 8
(3,559 Views)

Wall Ham wrote:

How can I create an if clause [in C++](not using the for loop once)

Should LabView contain an if clause?Smiley Wink


It does contain an 'if' clause. There's the case statement and the select function.

 

Please see the basic LabVIEW tutorials.

0 Kudos
Message 7 of 8
(3,554 Views)

Wall Ham wrote:

Should LabView contain an ...


LabVIEW is a complete programming environment and contains graphical equivalents of all elements found in other programming languages.

 

It's all there! 🙂

 

For very simple decisions, you could use a "select" node and for more advanced needs a case structure. Each case of a case structure contains alternative code, selected by whatever is wired to the selector terminal (works for integers, ranges of integers, strings, enums, errors, etc.).

0 Kudos
Message 8 of 8
(3,545 Views)