LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pretty basic help with a program

Hey guys,
 
I am developing a simple analysis program for my summer physics project. Sadly I do not have much experience with Labview and I seem to be running into a real problem.
 
In effect my project is to take a series of filter positions (which is in a file format of excel) and take the corresponding numbers for each filter position (1,2,4,6,8) and with another filter (1,2,4,6, or 😎 and assign that a variable. (so it could be 2,2, and assign that x1, 2,4 would be x2, etc. ) The reason they are coupled like this is because the beam travels through the filters in series, and the effects of the change in flux should be linear.
 
So in effect I am creating a large matrix with these numbers, and then I am trying to make a linear regression of this dataset. That is done just by cutting off the 2nd to last last set on the datasheet I am using (thats the photocurrent of the detector) and multiplying it by this large 40X150 matrix.
 
I have written a program that is pretty inelegant and basic, but even so it will not run, and I think it is very close to running. At this point I have been spending the last few days debugging it in hopes of finding the problem, and still no luck. So in my desperation, I am coming here hoping someone who is familiar with labview can take a look. I presume that at this point it is some small problem that arises from my lack of familiarity with labview.
 
The matrix I am creating is a 40X150 matrix, with 40 different positions for the filters to be assigned. I am pretty sure that the theory behind what I am doing is solid-I have taken linear algebra and written all the theory of my project out, so I think it is some sort of small detail I am missing. At this point the 40X150 zero matrix is not having any ones inserted into it, and I dont see why. I dont know where the problem is specifically sadly.
 
Thanks a ton!
 
NM
0 Kudos
Message 1 of 15
(2,993 Views)

One last thing: I have attached in this file the data set of a test...

NM

0 Kudos
Message 2 of 15
(2,988 Views)
First of all, I would like to make some suggestions which will make your program easier to follow.  One big problem with your program is the fact that it covers so much screen.  Most LabVIEW programmers make a point of keeping the size of the block diagram down.  It appears that you are already designating the function of portions of your code.  If you would segregate those portions of code into subvis you could quickly clean up your block diagram. 
 
Also, in order to find out if a number is even or odd use the quotient and remainder function with 2 as the divisor.  If the remainder is zero then the number is even.  If the remainder is 1 then the number is odd.  This is much better than anding all of those values together.
 
Finally, the portion of your code where you say that you are "inserting 1's into the 40 row matrix" doesn't have any kind of array (see attached image), so how are you inserting the ones?
 
This is just a few observations from a quick review of your code. 

Message Edited by John Rich on 07-22-2005 01:40 PM

0 Kudos
Message 3 of 15
(2,983 Views)

I like the extensive annotations, but your code makes little sense to me. In addition to what John Rich said, could you explain the purpose of the two FOR loops? You basically rattle through 150 elements just to read one element. (???)

(1) If you really need the FOR loops, you can combine them into one. You also duplicate operations for column 3, this needs ot be done only once, you can split the result later

(2) In this particular case, you can delete both FOR loops and wire 149 to the row inputs of the index array functions. Same result, <1% of the CPU load!

(3) Please match the data types of the indicators to the data type of the wires. Since you later need matrix operations where everything needs to be DBL, maybe you should initialize your array with DBL zeroes instead of I32, and make the blue 2D array orange.

(4) Instead of ANDing all the "not equals", you could OR the equals. Compare your test number with an array of test values, then OR the array elements. It makes the diagram easier to read.

(5) Notice that you can resize "index array". One single long index array node can replace the entire lower right part of your diagram. 🙂

0 Kudos
Message 4 of 15
(2,971 Views)
In addition to the things already mentioned you should be very careful about doing "equals" or "not equals" comparisons on non-integers. Due to the way these numbers are represented internally you may never get exactly equal numbers. For example 1.999999999999... is not equal to 2, but it is possible to get something like 1.999... from certain calculations which you would expect to produce 2. This can prevent something from working and have you pulling you hair out trying to figure out why.

Lynn
0 Kudos
Message 5 of 15
(2,961 Views)
Hey guys,
 
Thanks for the help already--I think it is, if nothing else, already improving my labview skills quite a bit.
 
 
I made a few changes and basically rewrote the code. No sub-vi yet, but certainly more readable now.
 
altenbach mentioned that I was not matching the wire type with the data type...how do you do this?
 
That index array resizing option is a lifesaver too.
 
And I noted that my original test to see if it was even was pretty crude--John Rich definitely provided the more elegant solution to that problem.
 
At least with the intent, there are no non integers being tested to be even, only the numbers 1,2,4,6,8,10 should be tested.
 
1)One thing that definitely could be the problem are the two (now one) FOR loop. What I want to do is take each element from a line (that is why the iteration number is wired into the row section of the index array.) and each time insert that (possibly) as a 1 value on the 40X120 array.

For example, if it is looking at line 23, that will be the 23 time the loop is running. It will go to that line and read each number from the file being used, and lets say it gets 2,2,2. So in this case, it will insert a one into the very first column of the matrix, and then insert a one into the 21 column of that matrix, all on the 23rd row.

It keeps doing this for every row, at least, that is what I want it to do 🙂
 
2) Does anyone have any experience with the write labview measurement file block? My program is suppose to run so that it will leave a 40 row single column vector at the end of it. Am I perhaps saving it wrong? I dont think I am because when I was indexing and examining the matrix it is still not returning anything but a matrix that has zeros in it, so it is still not inserting any ones for some reason...
 
Any additional help would be fantastic. Thanks again!
 
NM
 
 
 
 
0 Kudos
Message 6 of 15
(2,932 Views)
In order to match the wire type as Altenbach suggested you need to change the element that you're using when you create the array to a type DBL.  In order to do this just right click on the constant and select Representation.  This will give you the options of the different representations you can use.
 
You're code is certainly improved, although I would still suggest subvis in order to keep the left to right data flow. 
 
Your problem with the output is not with the file writing.  You are trying to invert a non-square matrix.  I suggest that you run execution highlighting and use probes at different locations in your program to see if the output that you're getting is what you expect.  For instance, if you expect at 140x1 array and you get a 140x50 array then you need to look at that portion of the code.
0 Kudos
Message 7 of 15
(2,912 Views)
How can I find the size of an array using the probe tool?
 
Additionally, I think the problem is that I am indeed getting an array from my FOR loop that is just a single element--the loop is not taking each of the iterations and sending that value through the loop... does anyone know how I could modify my code to make this be the case?
 
Thanks,
 
NM

Message Edited by Nicholas on 07-25-2005 12:05 PM

0 Kudos
Message 8 of 15
(2,906 Views)
Create a custom probe that also indicates the array size. The possibilities are endless ;).
0 Kudos
Message 9 of 15
(2,899 Views)


@Nicholas wrote:
Additionally, I think the problem is that I am indeed getting an array from my FOR loop that is just a single element--the loop is not taking each of the iterations and sending that value through the loop... does anyone know how I could modify my code to make this be the case?

OK, this does not make sense. You are currently NOT getting an array from your FOR loop.

To do so, rIght-click on the desired tunnels and "enable indexing".

0 Kudos
Message 10 of 15
(2,897 Views)