converted to matlab compatible code
ex4