minimum function
I wrote a program to correct the value of q. I wanted to choose always the minimum value and I put the maximum limit to be 15 MPa , I don't know why it is not working . Do you know how to solve this problem?
Thanks

I wrote a program to correct the value of q. I wanted to choose always the minimum value and I put the maximum limit to be 15 MPa , I don't know why it is not working . Do you know how to solve this problem?
Thanks

@YA_10963798 wrote:
Yes . I want it to be choose always the minimum value between the three valuesSo first it compares it to the previous value and choose the minimum and than to 12 MPa and choose the minimum. And then to the after value and choose the minimum. … this when the value is between (0 and 12)If the value between (12 and 15) it will remain the sameIf the value bigger than 15 it will choose 15.
First, let's look at your limiting program and see where it's going wrong.

If you look at the second value (index O+1), you want the minimum of qmin and the values at O and O+2, which are 12 MPa, 11.4 MPa and 15.8 MPa, respectively. The minimum of these is 11.4 MPa, which is what we see in result.
Rather than max(qmin,qclongi-1,qclongi+1) what you want is max(qmin,min(qmax,qclongi-1,qclongi+1)). IOW, you get the minimum of qmax and a values two neighbours and then the maximum of that and qmin. The min returns a value with a maximum value of qmax. The outer max returns the min value or qmin.
And then there are the end values. I've used q to limit them because q has the same values as qclong, and it's less typing and horizontal space (thus making it slightly more legible).

Stuart
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.