Post Reply 
Struggling with CAS programming
09-17-2018, 03:45 AM (This post was last modified: 09-17-2018 03:50 AM by rushfan.)
Post: #3
RE: Struggling with CAS programming
(09-17-2018 03:27 AM)Didier Lachieze Wrote:  Two things :
  1. I've found you need to declare your local variables before assigning them
  2. the line a(lpv,lpv+1) = 1; should be replaced by a[lpv,lpv+1]:=1;

Code:
#cas
tf2ss(num,den):=
BEGIN
// declare vars and allocate matrices
local ordem,a,b,c,d;
ordem := size(den)-1;
a:= identity(ordem)*0;
b:= identity(ordem)*0;
c:= revlist(num);
d:=0;
// fill A is in the form [0 1 0; 0 0 1; -p/m -o/m -n/m], where n m o p are from den
a:= replace(a,{ordem,1},-revlist(den[2..(ordem+1)])/den(1));
FOR lpv FROM 1 TO ordem-1 DO
a[lpv,lpv+1]:=1;
end;
// fill b 
b:= delrows(b,2..ordem);
b:= replace(b,{1,ordem},[1]);
b:= tranpose(b);

return a;
return b;
return c;
return d;
END;
#end

The code still does not work, even with the changes proposed. It gives "Error: Unmatch control word"
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Struggling with CAS programming - rushfan - 09-17-2018, 12:54 AM
RE: Struggling with CAS programming - rushfan - 09-17-2018 03:45 AM



User(s) browsing this thread: 1 Guest(s)