Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hi All,
What is the formula to stack the zcal into a vector and rearrange the vector up to the zcal value. Can anyone please advice?
Solved! Go to Solution.
Why didn't you attach your worksheet?
Try
This approach will fail if no value in z.soil is larger than z.cal.
If this is a problem, you may use tray and catch to cope with it
Remarks
Now this approach would give a wrong result if ALL values in z.soil are larger than z.cal.
If z.cal is equal to a value in z.soil, this value will be seen twice at the end of the resulting vector - not sure if this is desired behaviour.
If the values in z.soil are not sorted, you should use sort(trim(....)).
Here is a version which also considers these points. I formulated it as function of z.cal because this makes testing all possible cases easier
Why didn't you attach your worksheet?
Try
This approach will fail if no value in z.soil is larger than z.cal.
If this is a problem, you may use tray and catch to cope with it
Remarks
Now this approach would give a wrong result if ALL values in z.soil are larger than z.cal.
If z.cal is equal to a value in z.soil, this value will be seen twice at the end of the resulting vector - not sure if this is desired behaviour.
If the values in z.soil are not sorted, you should use sort(trim(....)).
Here is a version which also considers these points. I formulated it as function of z.cal because this makes testing all possible cases easier
Here is a shorter approach which avoids Try and catch and deals with the 'special' cases with simple if-statements, which might be better readable and understandable.
Hi Werner,
Thanks for posting the solution. I found another solution in the forum from another user, I've done some modified in the loop and got the answer, Obviously your solution is better that captures the possibility of value more than the specified range. I will take your formula into my calculation.
@davidlimtw wrote:
Hi Werner,
Thanks for posting the solution. I found another solution in the forum from another user, I've done some modified in the loop and got the answer, Obviously your solution is better that captures the possibility of value more than the specified range. I will take your formula into my calculation.
It looks to me that your function also deals with values larger than the all values in the vector the very same way as mine.
Only difference is that in case you have a value which matches one of the value sin the vector, you will see it twice in the result.
If this is a problem, you may apply these modifications
Only difference to the variants I posted is now that in case z is smaller than all values in V your result would be a vector with twice the value of z. In your case this would occur if you provide a negative value and I guess this would never be the case in your application.
E.g. set z.LP:=0,6 m and you will see this