Integral of a Matrix Issue

Dear all, i'm trying to integrate a matrix to get a radial average mean temperature along three axial positions; however the codes always return the same matrix vlaue, instead of a single T mean value along axial site..
Does anyone know how could i get a real mean temperature value at each axial dirctection?
r=[0,5,10,15]
T=[300,310,320,335;
302,312,322,337;
305,315,325,340;] % as matrix 3*4
R_t=15 % radius
T*r'
fun=@(r)T*r'
integral(fun,0,r_t,'ArrayValued',true)
T_mean=(2./(r_t).^2).*integral(fun,0,r_t,'ArrayValued',true)
The output:
T = 3×4
300 310 320 335
302 312 322 337
305 315 325 340
T*r':
ans = 3×1
9775
9835
9925
integral(fun,0,r_t,'ArrayValued',true):
ans = 3×4
1.0e+04 *
3.3750 3.4875 3.6000 3.7687
3.3975 3.5100 3.6225 3.7912
3.4312 3.5437 3.6562 3.8250
T_mean=(2./(r_t).^2).*integral(fun,0,r_t,'ArrayValued',true):
T_mean = 3×4
300.0000 310.0000 320.0000 335.0000
302.0000 312.0000 322.0000 337.0000
305.0000 315.0000 325.0000 340.0000
Thanks in advnce!!!!

 Accepted Answer

Why do you name the same radius R in the denominator R_T ? Both are equal to the cylinder radius (in your case 15, I guess).
r=[0,5,10,15];
T=[300,310,320,335;
302,312,322,337;
305,315,325,340];
Tr = r.*T;
T_mean_cyl = 2/r(end)^2 * trapz(r.',Tr.')
T_mean_cyl = 1×3
322.7778 324.7778 327.7778
%T_mean_cart = 1/r(end) * trapz(r.',T.')

4 Comments

@Torsten thank you so much sir!!! I didn't even realize the mistake of using same radius R_t value and to use trapezoidal intergration to solve my problems! Thank you very much again!
I will research more on trapz on matlab!
Dear @Torsten, Sir, I still have some questions regarding this issue. The following are the plots of the solution.
Then I further plotted the Temperature profile along the radius but only at z=1 as follows. (Assuming that z=[1 2 3])
z=[1,2,3]
r=[0,5,10,15] % radius
T_z_1=[300,310,320,335] % Temp at z=1 along r dimension
Ttest=r.*T_z_1
trapz(r.',Ttest.')
T_mean_test=2/r(end)^2*trapz(r.',Ttest.')
plot(T_mean_test,'b.','MarkerSize',20)
hold on
plot(r,T_z_1,'r.-','MarkerSize',20)
hold off
title('T vs r at z=1','FontSize',16)
xlabel('r [m]')
ylabel('T [K]')
legend('T\_mean\_test','T at z=1')
My questions are:
  1. Why the Tr_mean is shown higher than Tr=10? (I was expecting Tr_mean lower than Tr_10......I know this is from the calculated formula, but could you please explain to me in detail? It will be super helpful! I wonder if it's becasue of the cross area integration through the radius? But how?)
  2. For the second graph, T vs r at z=1, why the corresponing radius of Tr_mean is at r=1?
  3. WIll it make the result a big difference if we choose to use integral function in this case?
Any advice is greatly appreiated!
Thanks in advance!
1.
Because the area of the cylinder grows with r^2 and not with r and the high temperature between r=10 and r=15 is weighted much more than the low temperature between r=0 and r=10.
2.
Use
plot([0 15],[T_mean_test,T_mean_test],'b','MarkerSize',20)
instead of
plot(T_mean_test,'b.','MarkerSize',20)
3.
r=[0,5,10,15];
T=[300,310,320,335;
302,312,322,337;
305,315,325,340];
for i = 1:3
fun = @(rq)2*pi*rq.*interp1(r,T(i,:),rq,'spline')/(pi*r(end)^2);
T_mean_test(i) = integral(fun,r(1),r(end));
end
T_mean_test
T_mean_test = 1×3
321.4815 323.4815 326.4815
Sir, for Question 1, you said that cylinder goes with r^2, do you mean "the r inside the integral will becomes (r^2 /2) afterwards"? Right?
You must interprete the mean temperature as an area-weighted average, and the areas grow quadratically with r. Thus high temperatures for big r values influence the mean temperature more than low temperatures for small r. This is different for a plate where the areas are equal throughout.

Sign in to comment.

More Answers (0)

Products

Release

R2022a

Asked:

on 8 Nov 2022

Edited:

on 27 Mar 2023

Community Treasure Hunt

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

Start Hunting!