06-16-2013 11:06 AM
Could anyone help me that how can i save 100-200 equally spaced values of a particular number in labview?. Lets suppose i have a number of 50 and i need 100-200 equally spaced values between 0 to 50. I made a sample program but it gives memory storage error that i couldn't understand how to solve it....
Solved! Go to Solution.
06-16-2013 11:24 AM - edited 06-16-2013 01:18 PM
You are making the mistake of doing equal comparisons on floating point numbers. This is very dangerous. Most likely, your VI will never stop until the computer runs out of memory. Replace the "equal" with "greater or equal" and you should be OK.
Since you know the number of iterations beforehand, you should use a FOR loop. See how far you get. Also, your shift register should probably be initialized.
(Of course, there is also "ramp pattern" if you want a canned solution. ;))
06-16-2013 01:00 PM
Thanks. it works....
though i m new to labview so i didn't understand your last note about ramp pattern and canned solution...
06-16-2013 01:05 PM
He was referring to the Ramp Pattern.vi in the Signal Processing >> Signal Generation palette. It can do everything you want in one VI provided by NI with LV, hence "canned solution."
Lynn
06-16-2013 01:30 PM - edited 06-16-2013 01:30 PM
Essamuddin wrote:though i m new to labview so i didn't understand your last note about ramp pattern and canned solution...
A canned solution is like e.g. a can of soup, ready to heat and serve (like the ramp pattern function) while you could alternatively go to the farmers market, buy all ingredients, and make a soup from scratch. (similar to what you are trying to do with your program imitating the ramp function. :D)
Arguably, your home-made soup will probaby be better and have fewer questionable ingredients than the canned version. On the other hand, the ramp pattern from NI is a highly tuned and efficient piece of coding that will most likely beat any of your own attemps in terms of speed and memory efficiency. 😉
What is the purpose of all this? Do you simply need a ramp or are your trying to learn how to use loops and such in general?
06-16-2013 04:31 PM
Thanks once again for your valuable response.....
Actually i am trying to implement a small code in Labview. and i have to use these ramp like values to find another corresponding vector values through some mathematical equations and loops. I tried to make a program so could you help me in finding the errors and mistakes that i did in the attached file. The code and the resultant graph is attached.
06-16-2013 04:50 PM - edited 06-16-2013 04:51 PM
The for loop executes zero times. Why? Because the number of iterations is the minimum of N or the length of an autoindexed array input. Generally you should not both wire N and use autoindexing inputs. You have an empty array constant wired to the for loop so it executes zero times.
I think this may be your B vector. Use Initialize Array to create an array with a specified number of zero value elements.
Lynn
06-16-2013 06:26 PM
By initializing array for B vector the for loop runs for 100 iterations but at the output B vector has only two last values... Seems it updates the values with new one after two iterations instead indexing new values??....
06-16-2013 07:19 PM
You'll have to post your latest VI so we can see what might be doing that.
06-16-2013 08:53 PM
The indicator terminal for the B-Array is outside the for loop and the tunnel is set to Last Value (non-indexing). So it displays only the value from the 100th iteration of the for loop. If you change that tunnel to indexing, then you get a 2D array with 100 rows and 2 columns. The value in the second column is either the same as the value in the first column or zero. The values start at about 4.5 and decrease to -48.2. The zeros appear to result from the while loop stopping after the first iteration.
Lynn