Defining symbolically variables without computing it
古いコメントを表示
Hi, I would like to define variables symbolically (using an integral in this case), but without asking for Matlab to try to solve for that integral. And then later on feed to that integral some values so that it can compute the integrals. Hence how do I say that a variable is just the integral of something without asking for Matlab to symbolically solve that integral. Thank you Benoit
回答 (2 件)
Walter Roberson
2013 年 2 月 19 日
If you have the symbolic toolbox,
syms x y
f = x.^2 + 3*x*y - 5;
F = int(f, x, 0, 2); %over 0 to 2... notice y is still not defined
Fy = subs(F, y, 7); %evaluate at y=7
double(Fy) %if you need a numeric value instead of a symbolic value
1 件のコメント
Walter Roberson
2013 年 2 月 19 日
If you want to postpone evaluation of a symbolic expression, then you can place a call to the MuPAD-level function hold() or freeze()
You will need to use evalin(symengine) or feval(symengine) to access these calls, as they are not brought out to the MATLAB level.
Example:
feval(symengine, 'hold(int)', f, x, 0, 2)
Benoit
2013 年 2 月 19 日
0 投票
1 件のコメント
Walter Roberson
2013 年 2 月 19 日
Ambiguous. Do you mean that you want to postpone symbolic calculation until you fill in the values? Or do you mean that you want to tell MATLAB that the expression is going to be an integral, and that later you are going to want to do numeric integration to resolve the actual value?
If the latter, if you are going to be wanting numeric integration, then what value to you perceive in telling MATLAB that it will be an integral rather than just a symbol whose value will be determined later?
I have the sneaking feeling that what you really want is matlabFunction() applied to the symbolic integral.
カテゴリ
ヘルプ センター および File Exchange で Common Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!