Info

This question is closed. Reopen it to edit or answer.

2 integrals at once?

1 view (last 30 days)
Danielle Richard
Danielle Richard on 20 Sep 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi, I''m looking to get a numerical value for dG. The first two integrals are with respect to a same variable T, but the last one is with respect to a different variable, P. Is there a special notation when solving type of problem?
%Iterate Tmax until dG=0
Tmax=1100
dG=dH+integral(dCp1,1000,Tmax)-Tmax.*(dS+integral(dCp2,1000,Tmax))+ integral(dV1,1,P1)
  1 Comment
madhan ravi
madhan ravi on 20 Sep 2019
Provide the missing datas.

Answers (2)

Walter Roberson
Walter Roberson on 20 Sep 2019
No, there is no special notation.
What you pass as the first parameter to integral() must be the handle to a function that accepts one variable. It does not matter for the purpose of integral() what that variable represents or what you named it: it only cares that it can pass a value as the first parameter and get a result back.
If you do not pass 'arrayvalued', true to integral() as options, then the function must accept an array of x values and return something that is the same size.

Steven Lord
Steven Lord on 20 Sep 2019
The integral function doesn't care what name your integrand function uses for its input argument. All it really cares about is that your integrand function accepts an input argument and returns an output argument, and that both the input and the output arguments are the sizes described on the documentation page for the integral function. The expected size information is located in the fun input argument section.
fun1 = @(x) x.^2;
fun2 = @(elephant) elephant.^2;
fun3 = @(I_am_the_very_model_of_a_modern_major_general) ...
I_am_the_very_model_of_a_modern_major_general.^2;
y = zeros(3, 1);
y(1) = integral(fun1, 0, 5);
y(2) = integral(fun2, 0, 5);
y(3) = integral(fun3, 0, 5);
disp(y)
allResultsEqual = all(y == y(1))
y(1) is the result of , y(2) is the result of , and similarly for y(3).

Tags

Community Treasure Hunt

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

Start Hunting!