To my humble knowledge, such an algorithm or code that describes this function does not exist through the bibliography that I know of, maybe there is in another form of specification.
I'm not exactly sure of what you are asking. Are you looking for a way to generate "ramps with horizontal shoulders" (see figure) using some mathematical functions?
You can manually construct the desired membership functions using some mathematical piecewise linear functions. However, if your intention is to find the degree of truth, there is a much easier way.
Use a fismf object, you can easily construct the desired membership functions. Next, use evalmf(mf, x) to evaluate the membership function mf based on the input values in x, which returns the degree of truth. For more info, please look up:
https://www.mathworks.com/help/fuzzy/fismf.html
https://www.mathworks.com/help/fuzzy/evalmf.html
If they are not what you are looking for, then you might be referring to the following:
1) Inference
2) Degree of truth of the Aggregated Output Fuzzy Set