# How to write a function that its plot is like a “M” in MATLAB

I wrote a code in MATLAB that solves parabolic equation of two space (heat equation:$u_t = u_{xx} + u_{yy}$ )with ADI (Alternating direction implicit) method (finite difference method).

Now in order to test my code for initial function I want to write a function with two variables that is like "M" ,I mean that in $x-y$ points of "M" it's $z = 1$ and in the other points $z = 0$! I don't have any idea that how I can write this. suppose $x$ is in $[a,b]$ and $y$ is in $[c,d]$.

• What do you mean by there is no limit on x and y ? You add then that x is in [a,b] and y in [c,d] so x and y are bounded... You could try to define your function as a piecewise-defined function for which you choose the limit of your intervals in order to describe each part of your 'M'... – Coriolis May 29 '16 at 7:48
• you are right !I meant $x \in [a,b],y \in [c,d]$ – haleh May 29 '16 at 8:58
• It was difficult for me to be sure what you wanted, so I made an educated guess. Consider rephrasing the question, especially if I am off the mark. – Carl Christian May 29 '16 at 18:46
• Perhaps the function imread might be helpful here? – Kirill May 30 '16 at 2:36

Not a function, but as Kirill said in the comments, you could use imread.
M_bmp = imread('M.bmp') ;

I suppose that the simplest thing for you to do is to draw your $M$ on a piece of quadrille paper, i.e. paper with pre-printed squares. Embed your $M$ inside a square $S$ of a suitable size, say, 20 by 20 squares. The square $S$ will correspond to your box, i.e. $[a,b] \times [c,d]$. Do not bother with too much detail, but fill out each of the 400 small sub squares as needed to get a nice $M$. Create a table with $T$ with 400 entries and let $T(k)=1$ if an only if cell $k$ is part of your $M$ and $T(k)=0$ otherwise.