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
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
I want to write one equation for all of them like the one in the yellow box
Solved! Go to Solution.
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!
Prime 9 file attached
What is the meaning of below the answer you want?
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!
Prime 9 file attached
That works perfectly for some and not for others, How can I solve this problem?
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
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:
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:
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
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
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:
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.
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:
The error traces back to this line in your function and moans about an invalid index
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:
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.
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.
Prime 9 sheet attached
@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?
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.