Syntax error in MATLAB recurrence equation

matlab, mupad

Solution

`rec` is not a native Symbolic Toolbox function. It belongs to MuPAD which is a separate package that Mathworks acquired and added to Symbolic Toolbox. To use it you need to first enter `mupad` command in command window then you enter the command that uses `rec` in MuPAD window that pops up.

Problem

I have looked up here how to declare recurrence equations. I tried the following example from that page: ``` >> solve(rec(y(n + 1) = 3*(n + 1)*y(n), y(n), {y(0) = 1})) | Error: The expression to the left of the equals sign is not a valid target for an assignment. ``` Then I noticed that I didn't have the `Symbolic Math Toolbox` installed. After the installation ``` >> ver ``` returned (among some others): ``` MATLAB Version 8.1 (R2013a) Symbolic Math Toolbox Version 5.10 (R2013a) ``` but I still got the above error. I could narrow the command down to the following, giving the same above error: ``` >> rec(y(n + 1) = y(n), y(n), {y(0) = 1}) | Error: The expression to the left of the equals sign is not a valid target for an assignment. ``` On the wiki and other google results, the error is only mentioned with a error when confusing `=` with `==`.

Original source