Extract of data for the last time step
Show older comments
I have tried to extract theta at the middle of the array for all t. Please, how can I extract theta middle that correspond to the last time step? See the my code:
N = 100;
%% Numerical setup
% step size
h = d/N;
tspan = 0:2000; % Nonlinear case
nt=length(tspan);
% range of z
z=linspace(0,d,N+1);
% initial conditions
Theta = 0.0001;
theta0 = Theta*sin(pi*z/d); % Initial condition: 0
v0 = zeros(1,N+1);
theta0_int=theta0(2:N);
v0_int=v0(2:N);
u0 = [theta0_int'; v0_int'];
% Matrix M
M1=eye(N-1,N-1);
M2=zeros(N-1,N-1);
M=[M1 M2;M2 M2];
% Boundary Conditions
Phi_b = 0;
%% ode solver
counter = 0;
Xis = xi;
for xiidx = 1:length(Xis)
xi = Xis(xiidx);
for Uis = u
options = odeset('Mass',M,'RelTol',1e-4,'AbsTol',1e-6);
tic
[t,y] = ode15s(@(t,y)lcode1(t, y), tspan,u0, options);
toc
% Extract the solution for theta and v
theta = [Phi_b*ones(length(t), 1) y(:,1:N-1) Phi_b*ones(length(t), 1)];
v = [zeros(length(t), 1) y(:,N:(2*N-2)) zeros(length(t), 1)];
% Extract theta and v data for various xi
counter = counter + 1;
THETA(counter,:,:) = theta;
V(counter,:,:) = v;
% theta at the middle of the layer (i.e., z=d/2)
theta_middle(counter,:,:) = theta(:, N/2 +1);
end
end
2 Comments
Jan
on 2 Dec 2022
I struggle with the term "theta middle at the last for last time step". What does it mean?
University Glasgow
on 2 Dec 2022
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!