MATLAB Answers

''Conversion to logical from sym is not possible.'' Please help

3 views (last 30 days)
Anupam Ghosh
Anupam Ghosh on 13 Mar 2018
Commented: Anupam Ghosh on 14 Mar 2018
%This is a program on Continuous Fraction Expansion into a proper fraction using MATLAB. My program is attached...
clc; clear all;
syms s y z lo
% s=tf('s')
xy=1+(y*(s-1)/lo);
z=xy;
y=0.5;
lo=7;
n=3;
for m=6:-1:0
if mod(m,2)==0
lo=2+((n+y)*(s-1)/lo);
z=lo;
n=n-1;
else
xy=1+(y*(s-1)/lo);
lo=m+((n-y)*(s-1)/z);
% if m==6
% lo=7;
% end
end
end
disp('xy=')
pretty(xy)
% tf(xy)
% tol = 1.e-6*norm(xy(:),1);
[N,D] = rat(xy);
% fy=subs(xy,lo,7);
% disp('fy=')
% pretty(fy)

Accepted Answer

KSSV
KSSV on 13 Mar 2018
You cannot use rat on the class sym. Use simplify instead.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by