How to integrate a matrix of a certain dimension?!

Suppose I have a temperature matrix, T = zeros(Nz+1,Nt+1). Nz are number of elements in the z-axis and Nt are number of elements in the time-axis.
What command should I use for calculating the following integral?
E = integral of [A*T(z,:)*exp(-B*z)] with limits z = 0 to L.
Here, the temperature inside the integral is a function of the position z at a certain time.
Any kind of help will be appreciated. Thanks.

6 commentaires

Is that intended to be a single integral?? Neither your z nor your time are continuous, and you showed limits only for z.
I am wondering if you want is more or less the 2D equivalent of trapz() ?
Shashank
Shashank le 19 Déc 2012
Walter, yes it is a single integral. I am trying to compute the integral at every time step. This is what my algorithm looks like:
1. I assume a temperature profile within the solid (from z=0 to z=L) to be arbitrary at t=0.
2. I use the following equation to calculate the boundary condition at z=0 at the next time step: T(z=0, delta-t) = (A + B + C)^0.25. Here, A and B are constants and C is the integral defined as: Integral of ((T(function of z at t=0)^4)*exp(z)*dz) from z=0 to z=L.
3. Then, I solve for T(at all z, delta t) using a simple explicit equation that relates the temperature T at the next time step in terms of the T at the previous time step.
4. I solve this till I reach t = end time.
Shashank
Shashank le 19 Déc 2012
I am only facing problem solving that integral, can you please help me with it?!
I don't think I really understand, but as your z is discrete, you should probably use trapz()
Walter, could you help with the syntax for trapz() in my case?!
Nt = 100; Nz = 100;
dz = 1/100;
z = 0:dz:Lz;
TSi = zeros(Nz+1,Nt+1);
Y(i) = (TSi(1:end,i).^4)*exp(-A*z);
% A is a constant, "i" is the ith timestep
T_integral(i) = trapz(z,Y(i));
I am having trouble with dimension mismatch. Could you please tell me how to define Y such that it integrates over ith column of TSi only?!
Shashank
Shashank le 19 Déc 2012
Or is there a way to convert the temperature data points into a polynomial so that calculation becomes easy? Maybe use a curve-fit?

Connectez-vous pour commenter.

Catégories

Question posée :

le 19 Déc 2012

Community Treasure Hunt

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

Start Hunting!

Translated by