The vector q.avg which you obviously want to modify contains 12 elements.
But the vector thickness contains only 11 elements.
So its not clear which thickness should be assigned to the elements of q.avg.
I also wonder about the last entry (-16) in vector thick ...

I also don't understand your second min usage with three inputs and also not your last max/min combinations. They do not correspond to what you have explained in your text.
So just looking at what you have written that you need, it looks to me that q.avg and thick should be of the same length and that each entry in thick correspond to an entry in q.avg. And if the corresponding thick value to an q.avg value is smaller or larger than 2 m, different upper limits for q are used.
If thats true, you have to provide two vectors of equal length and the following function should do its job.

For example

Personally I would prefer to write the function just for scalars and then call it vectorized

but that may be subject of personal tast.