MATLAB: How to plot a surface with changing constant

changing constant

Hi guys,
I have a complex question. I want to graph the following equation as a surface. However, the constant A changes with a certain value of the y-axis:
Want to graph: z = M – 10x – 3.5y
Where
M = 5 + 3 for y < 10
M = 5 + 4 for 10 < y < 20
M = 5 + 5 for 20 < y < 30
Does this make sense? The value of the constant depends on the value of the y.
How can I approach this?
Thanks

Best Answer

I suggest this as a possibility:
M = [3 4 5];
z = @(x,y) 5 + M(max(1,fix((y-30+0.1)/10)+3)) - 10.*x - 3.5.*y;
I tested the M-matrix addressing with this statement:
Mr = [y' max(1,(fix((y-30)/10)+3))' M(max(1,fix((y-30+0.1)/10)+3))']
The surface plot is an inclined plane.