It sometimes gives you this error if you don't have the right toolboxes installed for the certain function.
If a particular function is causing an error. Try typing
If this results in like a certain toolbox is required for this function to work. Just click on the hyperlink or underlined link which is given in the terminal.
It will direct you to the appropriate package. Make sure you save any programs. Since installing the packages requires MATLAB to restart.