MATLAB: Do I receive an error when I run this code

Why do I receive an error when I run this code?
sys=tf([1],[1 1],'InputDelay',2)
sysd=c2d(sys,0.5)
[num,den]=tfdata(sysd)
num=num2str(num{:})
den=num2str(den{:})
num=poly2sym(num,z)
den=poly2sym(den,z)
num=char(num)
den=char(den)

Best Answer

Bad use of the poly2sym function, you give a string for the first argument but the function expects one array.
Also the z should be like this 'z'
doc poly2sym
Just a tip: num{:} gives you one array, that array can be used by poly2sym
sys=tf([1],[1 1],'InputDelay',2)
sysd=c2d(sys,0.5)
[num,den]=tfdata(sysd)
num=vpa(poly2sym(num{:},'z'),4)
den=vpa(poly2sym(den{:},'z'),4)
nums=char(num)
dens=char(den)
There were some errors, I had to edit the answer several times but I think that now it's all working.