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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

functions in matrices

YA_10963798
8-Gravel

functions in matrices

Hi there,

I want to write one equation for serveral matrics , however I can do that if I define a variable by equation not a funcation 

YA_10963798_0-1712403386810.png

I want to write one equation for all of them like the one in the yellow box

YA_10963798_1-1712403734007.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

I guess that "lookup" is more suitable for your needs than "match".

See if the attached helps. It was necessary to use " -d " because the values in vectors d are positive, but the values in the vectors z are negative!

Werner_E_0-1712412194929.png

Prime 9 file attached

 

View solution in original post

16 REPLIES 16
ttokoro
20-Turquoise
(To:YA_10963798)

image.pngimage.pngimage.pngimage.png

What is the meaning of below the answer you want?

image.png

d is the length while z is the depth I want these two values to be always associated with each other and then connected them to Q values

I guess that "lookup" is more suitable for your needs than "match".

See if the attached helps. It was necessary to use " -d " because the values in vectors d are positive, but the values in the vectors z are negative!

Werner_E_0-1712412194929.png

Prime 9 file attached

 

That works perfectly for some and not for others, How can I solve this problem?

YA_10963798_0-1712436341900.png

YA_10963798_0-1712439580950.png

 

 

 

What you show is a completely different situation!
For instance is q.c;tip a FUNCTION and NOT A VECTOR, so you can't index it with the range variabe i.n. Thats what the error message tries to tell you. You can often trace back an error to its root using the the tracing option on the calculation ribbon.

 

To achieve what you possibly try to do, you may use

Werner_E_0-1712439514560.png

Here looping through the values in the z and q.cza vectors is done using the range variable i.n.

 

But you can also do it without that range variable. With the following approach the looping is achieved using vectorization:

Werner_E_1-1712439701879.png

 

A third approach uses an explicit programmed for-loop to do the job. A bit more space consuming but maybe also a bit clearer to read and understand:

Werner_E_2-1712439899343.png

 

So you have the choice 😉

 

Prime 9 sheet attached

 

 

 

actually this work only for one value ztip in each CPT. I need to use ztips which is more than one value in the CPTs

YA_10963798_0-1712440795726.png

 

In your setup which I used z.tip was a simple scalar!?

So what kind of data structure you expect q.b;max to be?

The attached file is shown the same calculations but I did separate calculation for each CPT. In the sheet we are editing now I'm trying to write only one equation for all CPTs since we may have to calculate for more than 20 CPT in the future, 

So in this worksheet I used first z;tip and at the end I used z;tips to find all the values in each CPT. 

what I need to do is to find qb;max for all ztips and also find Rb;cal;max for all ztips

YA_10963798_0-1712442053755.png

 

I just noticed that you also had defines a variable z.tips. But this variable is NOT A VECTOR but rather a RANGE!!! Quite a difference even they may look the same when evaluated.

I used an undocumented trick to quickly turn that range into a 23-elements vector ztips:

Werner_E_0-1712442905806.png

We now could modify each of the posted three methods to generate nested vector a q.b;max which then is a 6-element vector and each element would be a 23-element vector corresponding to the values in ztips.

The modification for the third method would look like this - an outer loop (i) which cycles through the six z and q.cza vectors and a nested inner loop (j) which cycles through the 23 ztips values.

Werner_E_1-1712443149874.png

Unfortunately, as you can see, an error is thrown in your function q.c;tip. I traced it back and found that its thrown when i=3 and j=2.

Here is the error using these values:

Werner_E_2-1712443246766.png

The error traces back to this line in your function and moans about an invalid index

Werner_E_3-1712443409647.png

I don't k now what you are trying to do here and don't want to dig any further into that function but I guess that the "j" in your function in this case is already the last index and so there is no element with index j+1, which finally throws that error.

You have to correct that in your function and then you could calculate q.b;max as shown above.

 

As the error seems to occur with the data in CPT3, just for demonstration I limited the outer loop so the program only returns the results for the data in CPT1 and CPT2. This is what it looks like - hope its what you expect:

Werner_E_4-1712443917067.png

 

 

 

 

Ok I will do that,
Thanks for your advice, I appreciate your help

For completeness sake here are the modified versions which all create the same nested vector using all the 23 values of ztips.
I guess that the last one with the explicit for-loops is the one which can be read and understood most easily.

Werner_E_0-1712453135993.png

They should all work OK and give the very same result, once you fix the bug in your q.c;tip function.

 

EDIT: I modified your function in a way so that it does not throw the error anymore but you sure should do it in a better way as mine is just a brute force way to eliminate the error - not sure if the results still are valid.

Werner_E_1-1712454405610.png

 

Prime 9 sheet attached

 

 

I will try that thank you sooooo much


@YA_10963798 wrote:
I will try that

Keep in mind that I DID NOT FIX your function! I simply added the if...else... statements to avoid the error so that we see that the three methods to created the nested vector work and yield the very same result.

You will have to investigate some time to find out how to correctly fix your function so that it will not throw an error but also yield the correct result(s). Good luck!

I'm sorry for asking so many questions

but I did the same but it is still showing the same mistake. Can you please help me with that?

YA_10963798_0-1712521882706.png

 

I guess that z.tips still is a range. To turn the range into a vector you must write

ztips:=z.tips=

The equal sign at the end which evaluates the expression is mandatory - this is exactly the undocumented trick which turn the range into a vector.

Without that equal sign ztips is the same range as z.tips and therefore you get the error message that the function "last" must be applied to a vector.

It works, thank you.
You are the best.

Top Tags