topic Re: labview / array function inside for loop implementation in LabVIEW
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253001#M948194
<BLOCKQUOTE><HR /><LI-USER uid="331885"></LI-USER> wrote:<BR /><P>Hello, I have gone through basic tutorials and documentations.</P><P>But Cant find out solution for implementing below array function(<SPAN>y= y +(A[i]* T);</SPAN>) inside a loop. please hlep me out.</P><P> </P><P>Float y=0;</P><P>Float T=273;</P><P>A= { 1,2,3,4};</P><P>For (int i=0; i<=4;i++)</P><P>{</P><P>y= y +(A[i]* T);</P><P>}</P><HR /></BLOCKQUOTE><P>Look at your For loop description. While I'm not a C/C++ expert, I think the formulation "For (int i=0; i<=4;i++} will run 5 times, with i taking on the values 0, 1, 2, 3, 4. Now look at your array A -- it only has 4 values. Is this a bug in the Question?</P><P> </P><P>What happens inside the loop? One way of looking at it is that you are adding up a cumulative sum (initializing y to 0 and then adding A[i]*T each time through the loop). But if you have the Array A, you can multiply it by a scalar, T, and sum the elements of the Array with the Sum function found on the Numeric palette.</P><P> </P><P>Since you are <U>giving</U> the values of A and T, the problem is (almost) trivial, as you would learn when you spend time with the Tutorials. Form the A array, form the T constant, multiply them, sum the array element, save as the answer "y".</P><P> </P><P>So I agree with Crossrulz. It is always better to look at the Entire Problem, think a bit about it, and be willing to take the "simpler, better" solution. [A Famous Story concerns Gauss being asked to sum the numbers 1 through 100, and writing down the answer, 5050, "by inspection" instead of tediously adding 1 + 2 + 3 ...].</P><P> </P><P>Bob Schor</P>Sun, 14 Feb 2016 02:56:13 GMTBob_Schor2016-02-14T02:56:13Zlabview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252964#M948173
<P>Hello, I have gone through basic tutorials and documentations.</P><P>But Cant find out solution for implementing below array function(<SPAN>y= y +(A[i]* T);</SPAN>) inside a loop. please hlep me out.</P><P> </P><P>Float y=0;</P><P>Float T=273;</P><P>A= { 1,2,3,4};</P><P>For (int i=0; i<=4;i++)</P><P>{</P><P>y= y +(A[i]* T);</P><P>}</P>Sat, 13 Feb 2016 18:29:29 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252964#M948173prem.s2412016-02-13T18:29:29ZRe: labview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252965#M948174
<P>I see you already have the auto-indexing tunnel for the array and the For Loop. That is a good start.</P><P>Store the y value in a shift register that is initialized to zero. (Shift registers are also a very important LabVIEW concept.)</P><P> </P><P>All the rest is very basic math calculations and you should be able to figure out.</P><P> </P><P>I would recommend looking at the online LabVIEW tutorials<BR /><A href="http://zone.ni.com/devzone/cda/tut/p/id/5243" target="_blank"><FONT color="#3366cc">LabVIEW Introduction Course </FONT><FONT color="#3366cc">- Three Hours</FONT></A><BR /><A href="http://zone.ni.com/devzone/cda/tut/p/id/5241" target="_blank"><FONT color="#3366cc">LabVIEW Introduction Course </FONT><FONT color="#3366cc">- Six Hours</FONT></A></P>Sat, 13 Feb 2016 19:06:42 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252965#M948174RavensFan2016-02-13T19:06:42ZRe: labview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252968#M948176
<P>try to write your code if you code not this code help you <BR />but Deliberately there is a mistake inside the code try to find it it will help you to understand better about code function in labview for your aim</P>Sat, 13 Feb 2016 19:32:05 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252968#M948176Hatef.fouladi2016-02-13T19:32:05ZRe: labview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252975#M948180
<P>Who needs a for loop? LabVIEW can work on the arrays directly.</P>Sat, 13 Feb 2016 20:13:19 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252975#M948180crossrulz2016-02-13T20:13:19ZRe: labview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252993#M948189
Crossrulz,<BR />Also your answer is correct and better way to find the answer<BR />but here important thing is not the answer of algorithm is algorithm itself<BR />because it is for training and learning and your answer is not what algorithm should be<BR />you produce array of number form 1 to 4 but as you see above you have to create it by auto indexing and by algorithm not manuallySun, 14 Feb 2016 02:04:34 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3252993#M948189Hatef.fouladi2016-02-14T02:04:34ZRe: labview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253001#M948194
<BLOCKQUOTE><HR /><LI-USER uid="331885"></LI-USER> wrote:<BR /><P>Hello, I have gone through basic tutorials and documentations.</P><P>But Cant find out solution for implementing below array function(<SPAN>y= y +(A[i]* T);</SPAN>) inside a loop. please hlep me out.</P><P> </P><P>Float y=0;</P><P>Float T=273;</P><P>A= { 1,2,3,4};</P><P>For (int i=0; i<=4;i++)</P><P>{</P><P>y= y +(A[i]* T);</P><P>}</P><HR /></BLOCKQUOTE><P>Look at your For loop description. While I'm not a C/C++ expert, I think the formulation "For (int i=0; i<=4;i++} will run 5 times, with i taking on the values 0, 1, 2, 3, 4. Now look at your array A -- it only has 4 values. Is this a bug in the Question?</P><P> </P><P>What happens inside the loop? One way of looking at it is that you are adding up a cumulative sum (initializing y to 0 and then adding A[i]*T each time through the loop). But if you have the Array A, you can multiply it by a scalar, T, and sum the elements of the Array with the Sum function found on the Numeric palette.</P><P> </P><P>Since you are <U>giving</U> the values of A and T, the problem is (almost) trivial, as you would learn when you spend time with the Tutorials. Form the A array, form the T constant, multiply them, sum the array element, save as the answer "y".</P><P> </P><P>So I agree with Crossrulz. It is always better to look at the Entire Problem, think a bit about it, and be willing to take the "simpler, better" solution. [A Famous Story concerns Gauss being asked to sum the numbers 1 through 100, and writing down the answer, 5050, "by inspection" instead of tediously adding 1 + 2 + 3 ...].</P><P> </P><P>Bob Schor</P>Sun, 14 Feb 2016 02:56:13 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253001#M948194Bob_Schor2016-02-14T02:56:13ZRe: labview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253004#M948196
Hatef,<BR /><BR />I think you should have placed a period after 'better way to find the answer' and skipped all of the rest of your comment.Sun, 14 Feb 2016 03:12:02 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253004#M948196Dennis_Knutson2016-02-14T03:12:02ZRe: labview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253005#M948197
<P><img id="catvery-happy" class="emoticon emoticon-catvery-happy" src="https://ni.i.lithium.com/i/smilies/16x16_cat-very-happy.png" alt="Cat Very Happy" title="Cat Very Happy" /><BR /><SPAN>Dennis_Knutson</SPAN></P><P><SPAN>Maybe you are right.</SPAN><BR /><SPAN>But if we want to help one newer in LV programing I do not think giving easy and fastest way to solve one simple programing is right way </SPAN><BR /><SPAN>because he will be loose some information that might they could be helpful for big algorithms </SPAN><BR /><SPAN>what is your Idea to ask this person use that method you believe is best answer to present him to solve problem that require make large arrays ?! his question exactly is to find a way make array and do some operation on it not solving the answer</SPAN><BR /><SPAN>I think the totally the best answer that could be helpful for this friend is what Bob_Schor sent</SPAN></P><P><SPAN>totally the best answer that could be helpful for this friend is what Bob_Schor sent</SPAN></P><P><SPAN>totally the best answer that could be helpful for this friend is what Bob_Schor sent</SPAN></P><P><SPAN>best regard,<BR />Hatef</SPAN></P><P> </P>Sun, 14 Feb 2016 03:29:32 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253005#M948197Hatef.fouladi2016-02-14T03:29:32ZRe: labview / array function inside for loop implementation
https://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253007#M948198
labview / array function inside for loop implementation<BR />what this topic telling you ?!Sun, 14 Feb 2016 03:35:52 GMThttps://forums.ni.com/t5/LabVIEW/labview-array-function-inside-for-loop-implementation/m-p/3253007#M948198Hatef.fouladi2016-02-14T03:35:52Z