cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Custom Function - ignoring matrix variable...?

justhumm
10-Marble

Custom Function - ignoring matrix variable...?

I have a MathCAD Prime 7.0 worksheet and I created three custom functions, which are very similar.

 

The each seem to process variables somewhat correctly, but only one of the three will process a matrix/range variable even though I've tried using the same arguments for all three.

 

Any idea why the two later functions are treating the matrix/range variable as a constant?

 

Thanks!

 

ACCEPTED SOLUTION

Accepted Solutions

Vectorize the equations.  

Capture.JPG

View solution in original post

4 REPLIES 4

Vectorize the equations.  

Capture.JPG

Thanks @terryhendicott !

 

I'm just getting back into working with MathCAD after a few years hiatus...

 

Just for my own knowledge...why was the one function working okay without vectorization and the others weren't?

Werner_E
25-Diamond I
(To:justhumm)

On contrary to UDLv, your function UDLm calculates the product x*(L-x) and if x is a vector, then this is the product of two vectors and Prime correctly returns the dot (scalar) product and thats a scalar and not a vector. So all you see in your second plot is a single point.

Generally, when you define a function expecting all scalar arguments (as all you functions do) and you want to call it with a vector as an argument, you should apply vectorization.

 

But I see no reason for the vector i-L anyway. You just use it for plotting and you get a rather rough, inexact plot using just 11 points for the parabola.

Why not define a more dense range and use it for the plot?

Werner_E_0-1703888116616.png

 

 

Just for my own knowledge...why was the one function working okay without vectorization and the others weren't?

Capture.JPG

Pass a vector x into the above equation and the L/2-x is a scalar minus a vector that gets a vector, then a scalar times a vector that also gets a vector.

Capture2.JPG

Pass a vector x into the above equation and you eventually get a vector by vector product. Matrix multiplication is not defined for two column vectors but a dot scalar product is so you get one value.

Cheers

Announcements

Top Tags