‎05-01-2018 10:04 PM
Hello,
I am a beginner in labview. Can anyone please help me to convert the C programe code to labview code??
#include<stdio.h>
int main()
{
int array[]={1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,1,1,1,1,1,1,1,1,1,1,20,0,40,50,1,1,1,1,1,1,1,1,1,1,5,6,7,8,1,2,3,4};
int n = sizeof(array)/sizeof(array[0]);
printf("size of array is :%d \n", n);
int i;
for(i=0;i<n;i++)
{
int j=0;
int count=0;
if(array[i]==1)
{
j=i;
count=1;
while(array[j]==1)
{
j++;
count++;
}
if (count==10)
printf("your data is at %d location in array \n",i+count);
}
}
return 0;
}
Basically the code is finding a small sequence of data ,say 10 numbers from a large array of data, say 10000 numbers.
Solved! Go to Solution.
‎05-01-2018 10:11 PM
I assume you have looked over this: http://www.ni.com/academic/students/learn-labview/
Give it a go and post what you have completed so far so that we can give you specific pointers.
‎05-02-2018 12:45 AM
Hi sumesh,
Basically the code is finding a small sequence of data ,say 10 numbers from a large array of data, say 10000 numbers.
That's what that code does…
- You need a loop to run over your input array.
- You could use ArraySubset to read a subset of required length.
- You can compare this subset with your predefined pattern you are looking for.
- When both are the very same you can output this "pattern at location %d" message
That's a nice job to learn LabVIEW and some of it's very basic features! (Like autoindexing vs. non-indexing loop tunnels, comparison modes of compare functions, array handling and array functions…)
Show what you have tried and explain where you have failed!
(We will not do your homework!)
‎05-02-2018 07:07 AM
Just to add to the confusion, we goes use Flatten To String on both the data and the search criteria and then use Search/Split String to do the search for us...