LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multiply all elements of 1D array with constant number

I have an 1D array of elements and I want to muliply all elements of this 1D array with constant number let say 4. So can any body guide how can I multiply all the elements of 1D array with constant number?

 

Thanks 

 

JK

 

 

0 Kudos
Message 1 of 21
(17,517 Views)

You need to study a basic introductory course to LabVIEW, and read through the manual. It's counterproductive to start asking questions before at least having done that.

0 Kudos
Message 2 of 21
(17,515 Views)

What have you tried? Where did you get stuck?

Ever heard of this function? Try to combine it with this one.... 😄

0 Kudos
Message 3 of 21
(17,484 Views)

 

 What you might have initially tried was to add a Multiply function (Numeric-Multiply), wired your 1D array to one input, and then tried to create a numeric constant for the other input by right clicking on the node and selecting Create-Constant. Of course, this would have created an array constant, which is not what you want, and the resulting output would not have worked.

 

What you need to do instead is make your own numeric constant (Numeric-Numeric Constant) and wire that to the other input directly. Then the output of the Multiply function will be your input array times that constant.

 

 

Message 4 of 21
(17,225 Views)

riraheta wrote:

What you need to do instead is make your own numeric constant (Numeric-Numeric Constant) and wire that to the other input directly. Then the output of the Multiply function will be your input array times that constant.

 

I discovered this by trial and error, no thanks to the other two conceited pricks who "answered" this question earlier.


Umm, that's exactly what Altenbach suggested. You might note that his links are to the help for "Multiply" and "Numeric Constant." Not sure it could be much clearer than that.

0 Kudos
Message 5 of 21
(17,212 Views)
I reported him to the moderator.
0 Kudos
Message 6 of 21
(17,185 Views)

@riraheta wrote:

Wow all of you people are [smarter than me]. Thanks for nothing.

 

What you might have initially tried was to add a Multiply function (Numeric-Multiply), wired your 1D array to one input, and then tried to create a numeric constant for the other input by right clicking on the node and selecting Create-Constant. Of course, this would have created an array constant, which is not what you want, and the resulting output would not have worked.

 

What you need to do instead is make your own numeric constant (Numeric-Numeric Constant) and wire that to the other input directly. Then the output of the Multiply function will be your input array times that constant.

 

I discovered this by trial and error, no thanks to the other two conceited [crybaby insult] who "answered" this question earlier.


Perhaps you should read their replies before throwing a tantrum.  Then, you won't look as foolish.  You suggested the same thing they did. 

 

And, let's be fair.  If you're unable to understand something this basic, it's not really beneficial to hand you the answer.  They NEED to learn how to program if they're going to program.  If this is a task that's over their head, they DO need to take courses.  It's less than benevolent of you to insult others for pointing this out.

0 Kudos
Message 7 of 21
(17,169 Views)

Joseph,

 

I think the following link to polymorphic functions in LabVIEW might clear some things up.  This is something that is not immediately apparent to new users.

 

From the help document:

 

For operations involving a scalar and an array or cluster, LabVIEW performs the function on the scalar and the respective elements of the structure. For example, LabVIEW can subtract a number from all elements of an array, regardless of the dimensionality of the array.

 

http://zone.ni.com/reference/en-XX/help/371361L-01/lvconcepts/polymorphic_functions/

Matt J | National Instruments | CLA
0 Kudos
Message 8 of 21
(17,145 Views)

@riraheta wrote:

 

I discovered this by trial and error ...


Well, "trial and error" is probably not the right way to learn a new programming language. 😄

 

In any case, creating a constant on a terminal, if the other terminal is already wired  to an array, will create an array constant with the same dimensionality. If you would create a constant first, before wiring to the array, you would get a scalar. You simply need to hook things up in the correct order to minimze the extra work.

 

I agree that the current behavior is not optimal and that's exactly why I posted this idea about five years ago. Please vote for it! 😄

 

Message 9 of 21
(17,144 Views)

 Um, I think my account may have been somehow hacked.... I don't recall postng anything in this discussion...  Is there any way to close my account?  I fear that my emails may have been compromised.  Sorry for any inconveniences.

0 Kudos
Message 10 of 21
(17,129 Views)