undefined function of variable

"a person is considered "alive" if the mean temperature along the profile is greater than 22 degrees Celsius."
i gotta be able to show above line into my function. AND my output of function is only T (a vector of the temperature along the entire profile of the head), and aliveFlag (a flag either equal to 1 or 0 depending on whether the person is alive or dead, respectively).
How can i find mean temperature as mentioned in the above line?
if you have any questions regard to my problem, feel free to comment! thanks
% Spatial (r) parameters
L = 0.12; % Size of the domain
rstart = 0; % Start of computational domain (m)
rend = L; % End of computational domain (m)
nr = 101; % Number of grid points along the radius vector
dr = (rend-rstart)/(nr-1); % Spatial step size, delta r (m)
r = rstart:dr:rend; % Vector of grid points in r
% Temporal (t) parameters
timestart = 0; % Starting time (0 seconds)
dt = (timeend-timestart)/(nr-1); % Temporal step size, delta t (s)
time = timestart:dt:timeend; % Vector of times
% Phyiscal parameters
T1 = -41; % Temperature at r=0
T2 = 37; % Temperature at r=L
A = T2-T1; % Amplitude of the saw tooth wave
k = 0.527; % Thermal conductivity (W/m-K)
rho = 1000; % Density (kg/m^3)
gamma = 3600; % Heat capacity (J/kg-K)
c = sqrt(k/(rho*gamma)); % Heat equation constant
% Calculate B coefficients using a for loop
nfs = 1000; % Number of fourier terms
B = zeros(1,nfs); % Initialise B vector
lambda=zeros(1,nfs); % Initialise lambda vector
for n = 1:nfs;
B(n)=(2*A)/(n*pi); % Calculate B coefficients
lambda(n)=(n*pi*c)/L;
end
%% Solve for T using three for loops in time, space, and Fourier series
% Loop through time
for i = 1:nt % For each time
t = time(i); % time in seconds
% Vector of zeros to initialise the Fourier series solution.
% This should be re-initialised at each new time step.
T = zeros(1,nr);
% Loop through space
for j = 1:nr; % For each grid point
T(j) = (78*r(j))/L-41; % Add the steady state solution
% Loop through the Fourier series
for n = 1:nfs;
% Calculate series sum for T at r(j) and t
p=(n*pi)/L;
T(j) = T(j)+(156/(n*pi))*sin(n*pi*r(j)/L)*exp(-1*p^2*c^2*t);
end
end
end

3 个评论

You're overwriting T on every iteration of time. Is that as intended?
Also, once you have the T vector, you can simply use the mean function and apply the threshold.
T is intended.
Could you show me how to write that in code? haven't understood all the matlab skills yet.
If that is as intended, why do the loop in the first place? Why not only do the last iteration?
IsAlive= mean(T)>22;

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

评论:

Rik
2019-3-16

Community Treasure Hunt

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

Start Hunting!

Translated by