Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

02-13-2016 12:29 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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);

}

Highlighted
Options

02-13-2016 01:06 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

Highlighted
Options

02-13-2016 01:32 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

Highlighted
Options

There are only two ways to tell somebody thanks: Kudos and Marked Solutions

Unofficial Forum Rules and Guidelines

02-13-2016 02:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Who needs a for loop? LabVIEW can work on the arrays directly.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions

Unofficial Forum Rules and Guidelines

Highlighted
Options
Crossrulz,

Also your answer is correct and better way to find the answer

but here important thing is not the answer of algorithm is algorithm itself

because it is for training and learning and your answer is not what algorithm should be

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 manually

02-13-2016 08:04 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Also your answer is correct and better way to find the answer

but here important thing is not the answer of algorithm is algorithm itself

because it is for training and learning and your answer is not what algorithm should be

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 manually

Highlighted
Options

02-13-2016 08:56 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@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

Highlighted
Options
Hatef,

I think you should have placed a period after 'better way to find the answer' and skipped all of the rest of your comment.

02-13-2016 09:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

I think you should have placed a period after 'better way to find the answer' and skipped all of the rest of your comment.

Highlighted
Options

02-13-2016 09:29 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

Highlighted
Options

02-13-2016 09:35 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

labview / array function inside for loop implementation

what this topic telling you ?!

what this topic telling you ?!