MATLAB code and plotting the graph