[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Need help with eval
From: |
Doug Stewart |
Subject: |
Need help with eval |
Date: |
Sun, 02 Dec 2007 08:31:16 -0500 |
User-agent: |
Thunderbird 1.5.0.13 (Windows/20070809) |
I am using qtoctave with octave 2.9.15
When I copy and paste the results into eval it work as expected, but
when I try and do it inline in the code then it gives me errors.
here is part of the code so you can see how I am making the string.
else
if(abs(abs(c)-1)<10*eps) ## if c=1
if(c>=0)
if(b/a<0)
ss(q,1)=cellstr(sprintf(" e.^(t) .*(
cos(%g*t) %g *sin(%g*t))",d,(b/a),d)) ;
else
ss(q,1)=cellstr(sprintf(" e.^(t) .*( cos(%g*t) +
%g *sin(%g*t))",d,(b/a),d)) ;
endif
else
if(b/a<0)
ss(q,1)=cellstr(sprintf(" e.^(-t) .*( cos(%g*t)
%g *sin(%g*t))",d,(b/a),d)) ;
else
ss(q,1)=cellstr(sprintf(" e.^(-t) .*( cos(%g*t) + %g
*sin(%g*t))",d,(b/a),d)) ;
endif
endif
else
if(b/a<0)
ss(q,1)=cellstr(sprintf(" e.^(%g *t) .* ( cos(%g*t)
%g *sin(%g*t))",c,d,(b/a),d) );
else
ss(q,1)=cellstr(sprintf(" e.^(%g *t) .*( cos(%g*t) +
%g *sin(%g*t))",c,d,(b/a),d) );
endif
endif
endif
endif
q=q+1;
k=k-2;
endif
endif
endwhile
ss
%%w='f(t) = ';
w='yy= ';
for h=1:q-1
w=strcat(w,strvcat( ss(h,1)));
endfor
t=1:.01:3;
w
eval(w);
plot(t,yy);
ret=w;
endfunction
As you can see I am using a cell array and then putting all the cells
into one string at the last.
If I take and copy the screen results of w and use it in an eval( )
function at the command prompt it works!!
But this code gives:
w = yy= -0.0555556 * ( cos(3*t) + -1 *sin(3*t)) + 0.0555556 * e.^(-3*t)
error: operator .^: nonconformant arguments (op1 is 3x1, op2 is 1x201)
error: evaluating binary operator `.^' near line 209, column 62
error: evaluating binary operator `*' near line 209, column 59
error: evaluating binary operator `+' near line 209, column 47
error: evaluating assignment expression near line 209, column 3
error: called from `ilt' in file `E:\qtoctave-0.6.8\M\ilt.m'
you can get the code at dougs dot homeip dot net/octave/ilt.m
Obviously it is my attemp at doing the inverse laplace transforms.
to run this example use
n=1
d=poly([ +3j -3j -3 ])
sys=tf(n,d);
ilt(sys,'i')
Thanks in advance.
Doug Stewart
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Need help with eval,
Doug Stewart <=