02-13-2016 12:29 PM
Hello, I have gone through basic tutorials and documentations.
But Cant find out solution for implementing below array function(y= y +(A[i]* T);) inside a loop. please hlep me out.
Float y=0;
Float T=273;
A= { 1,2,3,4};
For (int i=0; i<=4;i++)
{
y= y +(A[i]* T);
}
02-13-2016 01:06 PM
I see you already have the auto-indexing tunnel for the array and the For Loop. That is a good start.
Store the y value in a shift register that is initialized to zero. (Shift registers are also a very important LabVIEW concept.)
All the rest is very basic math calculations and you should be able to figure out.
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
02-13-2016 01:32 PM
try to write your code if you code not this code help you
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
02-13-2016 02:13 PM
Who needs a for loop? LabVIEW can work on the arrays directly.
02-13-2016 08:04 PM
02-13-2016 08:56 PM
@prem.s241 wrote:Hello, I have gone through basic tutorials and documentations.
But Cant find out solution for implementing below array function(y= y +(A[i]* T);) inside a loop. please hlep me out.
Float y=0;
Float T=273;
A= { 1,2,3,4};
For (int i=0; i<=4;i++)
{
y= y +(A[i]* T);
}
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?
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.
Since you are giving 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".
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 ...].
Bob Schor
02-13-2016 09:12 PM
02-13-2016 09:29 PM
Dennis_Knutson
Maybe you are right.
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
because he will be loose some information that might they could be helpful for big algorithms
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
I think the totally the best answer that could be helpful for this friend is what Bob_Schor sent
totally the best answer that could be helpful for this friend is what Bob_Schor sent
totally the best answer that could be helpful for this friend is what Bob_Schor sent
best regard,
Hatef
02-13-2016 09:35 PM