How do I translate "rec" from MuPAD to MATLAB Symbolic Math Toolbox?
8 views (last 30 days)
Show older comments
MathWorks Support Team
on 26 May 2022
Answered: MathWorks Support Team
on 14 Sep 2022
If I use "convertMuPADNotebook" on a MuPAD file that contains the rec command, such as
rec(y(n + 2) = y(n + 1) + 4*y(n), y(n))
I see
%CODE TRANSLATION ISSUE 1 - aux1
%ERROR : Unable to translate calls to the function 'rec'.
aux1 = 'aux1Untranslated' % MuPAD code: rec(y(n + 2) = y(n + 1) + 4*y(n), y(n))
In the translated file.
Accepted Answer
MathWorks Support Team
on 26 May 2022
Currently "convertMuPADNotebook" does not translate "rec" from MuPAD to MATLAB. This issue has been reported to development and may change in a future release. To achieve this workflow use
syms y(n) z
assume(n>=0 & in(n, 'integer'))
f = y(n+2) - y(n+1) - 4 * y(n)
fZT = ztrans(f,n,z)
syms yZT
fZT = subs(fZT,ztrans(y(n),n,z),yZT)
yZT = solve(fZT, yZT)
ySol = iztrans(yZT,z,n);
ySol = simplify(ySol)
ySol1 = simplify(subs(ySol,[y(0) y(1)], [0 1]))
As per the "ztrans" documentation: https://www.mathworks.com/help/releases/R2022a/symbolic/compute-z-transforms-and-inverse-z-transforms.html
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!