how to get updated value of function everytime in the loop
1 view (last 30 days)
Show older comments
upinderjeet
on 28 Feb 2014
Commented: upinderjeet
on 28 Feb 2014
Hello. I am using the below code in the loop and here is the problem area. When I use the code(following)
for i=1:100,
G=i;
A=[-1/10 0;G -(1+10*G)/10];
B=[2 2 0;2 G G];
C=[1 -1];
I=[1 0;0 1];
syms s
Q=C*((s*I-A)^(-1))*B;
Q(2);
Q(3);
syms t
M=(ilaplace(Q(2),s,t))^2;
N=(ilaplace(Q(3),s,t))^2;
m=integral(M,0,Inf);
n=integral(N,0,Inf);
Sw=1;Sv=100;
Ess(i,:)=Sw*m+Sv*n;
We(i,:)=Sw*m;Ve(i,:)=Sv*n;
end
Error using integral (line 83) First input argument must be a function handle.
*now i think the error is in the line where I use M=(ilaplace(Q(2),s,t))^2; and N=(ilaplace(Q(3),s,t))^2;, but how else I can achieve to calculate the integral as each time the value of G is different in each loop and hence I cannot write M and N as function of t because it changes every time the loop is executed depending on the value of G. *
0 Comments
Accepted Answer
Walter Roberson
on 28 Feb 2014
Edited: Walter Roberson
on 28 Feb 2014
ilaplace is a symbolic transform, giving you a symbolic result. You need to convert the symbolic result to a function handle. See matlabFunction() for that.
Or you could consider using symbolic integration, int() instead of integral()
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!