modified matlab codes