フィルターのクリア

how to get updated value of function everytime in the loop

1 回表示 (過去 30 日間)
upinderjeet
upinderjeet 2014 年 2 月 28 日
コメント済み: upinderjeet 2014 年 2 月 28 日
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. *

採用された回答

Walter Roberson
Walter Roberson 2014 年 2 月 28 日
編集済み: Walter Roberson 2014 年 2 月 28 日
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()
  2 件のコメント
upinderjeet
upinderjeet 2014 年 2 月 28 日
Dont you think that in both the cases you recommend, I still have to write the expression for that symbolic function before I cud use a function handle or int. If I am right then how can I cater to the changing value of that expression every time the new loop is being executed.
upinderjeet
upinderjeet 2014 年 2 月 28 日
?????

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by