Skip to main content
1-Visitor
Jun 18, 2014 9:50 PM UTC
Question

Using a vector of values as an input for a function

I have the problem that I would like to use a function with a set of values which are in an array. For example measured values.

My problem is that inside the function is a multiplication, so the vector is multiplicated with another vector. But I do not want this, I just want mathcad to take each value and to give out a vector with the results for each value in the input vector. This works if a range is defined but not with a vector. I understand that there is a matrix multiplication, but is there no way to tell mathcad what I want to do? Here is an example:

vector+multiplication.png

8 replies

19-Tanzanite
Jun 18, 2014 10:05 PM UTC

Use the vectorize operator.

Translate
1-Visitor
Jun 18, 2014 10:21 PM UTC

Thank you for the quick answer! I found another solution, but I like yours more. Anyway you could work with matrix indices.

vector+multiplication2.png

There was an unanswered question where someone did it this way, just found it by accident.

Translate
19-Tanzanite
Jun 18, 2014 10:48 PM UTC

Yes, you can use indices. That is a method that will always work, but if vectorizing works (which is usually the case, but not always) it is a lot faster. With very big vectors it can make a noticeable difference.

Translate
1-Visitor
Jun 19, 2014 6:03 AM UTC

Have a read through the attached worksheets which have been passed in the forum many times.

Translate
Werner_E
25-Diamond I
Jun 19, 2014 10:45 AM UTC

That treatise about ranges and vectors from Stuart Bruff dating back to 2011 sure ist still worth reading for Prime users as well.

In case those users don't find a way to open files in real Mathcad format, find attached a pdf of both.

The Date at the lower left in the file is NOT the date the paper was written but just the date the pdf was created.

Translate
1-Visitor
Jun 19, 2014 10:55 AM UTC

Cheers Werner - I dare not try and convert to Prime!!!!

Translate