フィルターのクリア

Plot u vs. t with PDEPE. "Index exceeds matrix dimensions."

1 回表示 (過去 30 日間)
Jennifer Yang
Jennifer Yang 2018 年 8 月 10 日
コメント済み: Torsten 2018 年 8 月 16 日
Hello,
I can't seem to figure out how to plot u (concentration) vs. t (time) at a specific x (distance).
function simple_time_dependent_pdepe
clear all; close all; clc;
%
D_ij = 1*10^-6; %Diffusion coefficient D (3.0*10^-7 cm^2/s -> 30 um^2/s)
L0 = 1; %c0 [nM]
x_f =0.02; %Length of domain [um]
maxt = 10; %Max simulation time [s]
%
m = 0; %Parameter corresponding to the symmetry of the problem
x = linspace(0,x_f,100); %xmesh
t = linspace(0,maxt,100); %tspan
%
sol = pdepe(m,@DiffusionPDEfun,@DiffusionICfun,@DiffusionBCfun,x,t,[]);
u = sol;
%
% Plotting
plot(t,sol(:,500),'LineWidth',2)
function [c,f,s] = DiffusionPDEfun(x,t,u,dudx)
D = D_ij;
%
%Rate constants
k_1 = 0.25;
R_L = -k_1.*u;
%
% PDE
c = 1;
f = D_ij.*dudx;
s = R_L;
end
%
function u0 = DiffusionICfun(x)
u0 = 0;
end
%
function [pl,ql,pr,qr] = DiffusionBCfun(xl,ul,xr,ur,t)
c0 = L0;
pl = ul-c0;
ql = 0;
pr = 0;
qr = 1;
end
end
I tried using
plot(t,sol(:,500),'LineWidth',2)
However, I get the error "Index exceeds matrix dimensions."
Am I missing something?
  7 件のコメント
Jennifer Yang
Jennifer Yang 2018 年 8 月 15 日
I'm confused how to go about making the size the same so that I can plot sol vs. time at x = 500
Torsten
Torsten 2018 年 8 月 16 日
plot (t,sol(:,100,1))
plots the solution over time at x(100), e.g.
Does that help ?
Best wishes
Torsten.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by