12-12-2009 02:16 PM
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 advanced
12-12-2009 02:26 PM
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 ;))
12-12-2009 02:43 PM
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)
Thanks
Sorry to have wasted you're time
12-12-2009 02:49 PM - edited 12-12-2009 02:50 PM
Keep the counter and the sum in a shift register (or feedback node) each. Here's a draft:
What is your LabVIEW version?
12-12-2009 02:55 PM
My version is 2009 evaluation
12-12-2009 03:49 PM
How can I create an if clause [in C++](not using the for loop once)
Should LabView contain an if clause?
12-12-2009 04:26 PM
Wall Ham wrote:How can I create an if clause [in C++](not using the for loop once)
Should LabView contain an if clause?
It does contain an 'if' clause. There's the case statement and the select function.
Please see the basic LabVIEW tutorials.
12-12-2009 07:04 PM
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.).