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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Solving for values in a table

MH_10178519
7-Bedrock

Solving for values in a table

Would love help with this.  I've defined my function, inserted a table of values, and am expecting results in a vector format. 

MH_10178519_0-1642774552767.png

HELP!!

ACCEPTED SOLUTION

Accepted Solutions

Ahhh, thanks a ton!  This worked!  Next is to figure out how to plot!  

 

Thanks a bunch.

M

 

View solution in original post

14 REPLIES 14
LucMeekes
23-Emerald III
(To:MH_10178519)

Please attach the Prime worksheet, not just/only a picture.

Some upfront advice:

1. Make sure that k is defined.

2. Vectorize the expression at the right-hand side of the definition.

3. DON'T evaluate a definition. That is: do NOT put an '=' at the end of a definition. It may work in many cases, but in ever so many cases it leads to problems. Use a separate region to evaluate your expression.

 

Success!
Luc

Werner_E
25-Diamond I
(To:MH_10178519)

You have to delete the equal sign after the function definition and evaluate the function in a separate region.

Furthermore I guess you will have to vectorize the function call as you will get wrong results otherwise.

I second what Luc already said - attach the worksheet!

 

EDIT: Ahh, I see that in the meanwhile Luc has edited his reply and suggests quite the same 😉

Another option would be that you don't define a function but a simple variable eta:=...
In this case you would have to use vectorization as well but you could use inline evaluation (the = after the definition). But for some reason inline evaluations have proven to be instable in some situations and so I suggest not using it.

BTW, inline evaluation never works when defining a function.

 

File attached....

 

I am really new at this so I appreciate the patience...

 

When you say "vectorize" the function, how is that accomplished?  

Whoops, sorry, I was working on a different computer and the file did not save.  I'll upload revised shortly.

Updated worksheet attached.  Thanks!

Werner_E
25-Diamond I
(To:MH_10178519)

vectorizing is the operator which shows as an arrow over the expression:

Werner_E_0-1642776657835.png

You may note that you can define the function above the table with values. They need not to be defined when you define your function.

 

So I would suggest to either define a function beforehand and the call it vectorized and assign the result to a variable or simply assign the definition (which is less preferable in my opinion).

Werner_E_0-1642777377551.png

 

Ahhh, thanks a ton!  This worked!  Next is to figure out how to plot!  

 

Thanks a bunch.

M

 

Werner_E
25-Diamond I
(To:MH_10178519)

Have edited my reply and attached the work sheet

LucMeekes
23-Emerald III
(To:MH_10178519)

How to plot...

Assuming you'd want to plot the eta results, you'll have to decide what you want to plot it against:

r_c?

LucMeekes_1-1642788176436.png

 

or r_x?

LucMeekes_0-1642788131913.png

or all three?

LucMeekes_2-1642788511596.png

 

success!

Luc

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

vectorizing is the operator which shows as an arrow over the expression:

Werner_E_0-1642776657835.png

You may note that you can define the function above the table with values. They need not to be defined when you define your function.

 

So I would suggest to either define a function beforehand and the call it vectorized and assign the result to a variable or simply assign the definition (which is less preferable in my opinion).

Werner_E_0-1642777377551.png


I'd have been tempted to put the vectorize operator inside the function.

 

2022 01 22 a.png

 

Stuart

Add two statements:

Fred_Kohlhepp_0-1642776807295.png

You've defined  a function, which is what Prime is saying with the statement 

Fred_Kohlhepp_1-1642776900292.png

So you can define a variable (N) to evaluate each occurrance of the r_c, r_x, and r_k (which is what the "vectorization" (the arrow above the function) does, and then you can see each N.  (Which is what Luc and Werner were saying.)

 

I think i understand now.  if the variable is in a vector format, then the resulting equation or function must also be in a vector format...

LucMeekes
23-Emerald III
(To:MH_10178519)

"if the variable is in a vector format, then the resulting equation or function must also be in a vector format"

Often, but not necessarily. You can write a function

LucMeekes_0-1642779184024.png

that accepts two vectors

LucMeekes_1-1642779202920.pngLucMeekes_2-1642779210717.png

and results in a single number,

LucMeekes_3-1642779225303.png

or in a matrix

LucMeekes_4-1642779269419.png

(Note that

LucMeekes_5-1642779294097.png

)

But if you use vectors to hold sets of values that you want to operate on as sets, like you do here, you mostly need to vectorise the expression.

LucMeekes_6-1642779351166.png

and beware. The function:

LucMeekes_7-1642779542901.png

supplied with the same variables, results in respectively:

LucMeekes_8-1642779578589.png

LucMeekes_9-1642779586047.png(complaint that the array dimensions do not match)

LucMeekes_10-1642779629917.png(vectorisation results in no diffent operation for addition of two vectors)

 

Success!
Luc

StuartBruff
23-Emerald III
(To:MH_10178519)


@MH_10178519 wrote:

I think i understand now.  if the variable is in a vector format, then the resulting equation or function must also be in a vector format...


Just to amplify the point others have made, it's the nature of the vector operations that determine whether you need to vectorize a result.  Mathcad operators and functions generally have a vector/matrix interpretation if there is one, otherwise they will either raise an error or apply to each element of a vector/matrix.  For example, look at the difference between the outputs of vector dot product(*), matrix multiplication, vector power, vectorized multiplication and the sine function.

 

StuartBruff_0-1642861335273.png

 

Consequently, you only need to apply vectorization when you intend the operation to be element-by-element.

 

Stuart

 

(*) The dot product produces a scalar.   [1xn] * [nx1] matrix multiplication produces a [1x1] matrix.

Announcements

Top Tags