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

Answers (2)

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 Comment

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)

Sign in to comment.

You have exactly what I don't want: F is being symbolically computed. I don't want that. I just want that Matlab understands that I want F to be expressed as an integral and not as a symbolically computed integral.

1 Comment

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.

Sign in to comment.

Asked:

on 19 Feb 2013

Community Treasure Hunt

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

Start Hunting!