LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to add a series of random number in following pattern: (0.5(0.5(0.5x1+x2)+x3)+x4).... How to perform this in a while loop?

Solved!
Go to solution

As asked in the subject, can someone tell me how to do it?

0 Kudos
Message 1 of 8
(2,919 Views)

Will,

 

I would strongly suggest going through the 6-hour introduction to LabVIEW

 

http://www.ni.com/white-paper/5241/en/

 

I came up with a simple solution using shift registers to divide our previous iteration by two then add another random number and display that to the user.

 

Failure Mode xxx.png

 

 

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 8
(2,911 Views)

This might have been a homework assignment. Smiley Surprised

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

The result seems not as same as what I want. What you have there are 0.5x1+x2, 0.5x2+x3, 0.5x3+x4.......Am I right?

0 Kudos
Message 4 of 8
(2,898 Views)

Actually it is not. It is part of a project I am working on. I am struggling to convert from c to labview.

0 Kudos
Message 5 of 8
(2,895 Views)

I think you may need to swap the order of the divide by 2 and the addition.  I would intialize the shift register with a zero.

 

But beyond that, it seems correct.  Remember the shift register takes the value to the next iteration.  The value going into the shift register is equivalent to each set of parentheses.

0 Kudos
Message 6 of 8
(2,871 Views)
Solution
Accepted by topic author WilliamSun912

@WilliamSun912 wrote:

The result seems not as same as what I want. What you have there are 0.5x1+x2, 0.5x2+x3, 0.5x3+x4.......Am I right?


Out of the first iteration we will see X1 because we initialized the shift register with a rand().  The following two functions result in .5X1+X2.  That value gets passed to the next iteration, meaning we divide (.5X1+X1) by two.  After the addition we will then have .5(.5X1+X2)+X3.  This is what you wrote but because the series does not converge you will need to decide whether you want to read the value before or after you add the next random number.

 


@RavensFan wrote:

I think you may need to swap the order of the divide by 2 and the addition.  I would intialize the shift register with a zero.


Both ways should result in the same series, but they will pass different parts.  In my example we pass .5X1+X2 then .5(.5X1+X2)+X3.  If we do it your way we will first pass .5X1 then we will pass .5(.5X1+X2).  If we moved the indicator in my example to right after the left shift register and the indicator in your idea between the addition and division, they should read the same value each iteration.

 

 

Matt J | National Instruments | CLA
0 Kudos
Message 7 of 8
(2,860 Views)