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!