integral2 for a non-scalar matlabFunction
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to use integral2 for a non-scalar matlab function. In the following I define 3 symbolic functions, put 5 set of data for (y1, y2 and y3) , which in total makes it 15 functions. I convert them into anonymous function with "matlabFunction" so that I could use the integral2. The problem is integral2 is not working with this output. Is there a way around it ? The purpose is to vectorized the operation of integration to speed up the code.
syms zi eta
syms N1 N2 N3
syms y_1 y_2 y_3
N1=1-zi-eta;
N2=zi;
N3=eta;
N=[N1,N2,N3];
for i=1:3
cons_int(i)=N(i)*sinh(y_1.*N1+y_2.*N2+y_3.*N3);
end
y_1_val=[1:5]';
y_2_val=[1:5]';
y_3_val=[1:5]';
intagrand_temp=subs(cons_int,{y_1, y_2, y_3},{y_1_val,y_2_val,y_3_val});
if ~isempty(intagrand_temp)
intagrand_1 = matlabFunction(intagrand_temp);
zi_max = @(eta) 1 - eta;
q_cons = integral2(intagrand_1,0,1,0,zi_max);
end
0 Kommentare
Antworten (1)
Torsten
am 16 Jul. 2023
Verschoben: Torsten
am 16 Jul. 2023
"intagrand_temp" is a 5x3 matrix of symbolic functions in eta and zi. I don't understand which scalar-valued function(s) you want to integrate. Each of the 15 functions one by one to get a 5x3 matrix as result ?
Maybe like this ?
syms zi eta
syms N1 N2 N3
syms y_1 y_2 y_3
N1=1-zi-eta;
N2=zi;
N3=eta;
N=[N1,N2,N3];
for i=1:3
cons_int(i)=N(i)*sinh(y_1.*N1+y_2.*N2+y_3.*N3);
end
y_1_val=[1:5]';
y_2_val=[1:5]';
y_3_val=[1:5]';
intagrand_temp=subs(cons_int,{y_1, y_2, y_3},{y_1_val,y_2_val,y_3_val})
q_cons = int(int(intagrand_temp,zi,0,1-eta),eta,0,1)
6 Kommentare
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

