Z must be a matrix, not a scalar or vector when solving using surf in pdepe
Afficher commentaires plus anciens
I am not an expert in MATLAB and I did my best in coding my 5 PDE's using pdepe command but keep getting this massage?
Z must be a matrix, not a scalar or vector.
My codes are
m = 0;
x = linspace(-10,20,200);
t = linspace(1,20,100);
sol = pdepe(m,@chagastwpde,@chagastwic,@chagastwbc,x,t);
% Extract the first solution component as u.
u1 = sol(:,:,1);
u2 = sol(:,:,2);
u3 = sol(:,:,3);
u4 = sol(:,:,4);
u5 = sol(:,:,5);
figure
surf(x,t,u2)
title('Numerical solution of I_{ha}')
xlabel('Distance x')
ylabel('Time t')
function [c,f,s] = chagastwpde(x,t,u,DuDx)
c = [1;1;1;1;1];
f =[0 ;0 ;0 ;0.4 ; 0.4].*DuDx;
s1=(50*exp(-(1/100)*(u(1)+u(2)+u(3))))*(u(1)+0.1*(1-0.1)*u(2)+0.3*(1-.1)*u(3))-0.7*u(1)-((3*u(1)*u(5))/(u(1)+u(2)+u(3)))+0.7*u(2);
s2=(50*exp(-(1/100)*(u(1)+u(2)+u(3))))*((0.1*0.1*u(2))+0.3*0.1*u(3))+((3*u(1)*u(5))/(u(1)+u(2)+u(3)))-(0.7+0.2+0.7+0.4)*u(2);
s3=0.4*u(2)-(0.7+0.5)*u(3);
s4=100*(u(4)+u(5))*exp(-(1/200)*(u(4)+u(5)))-((0.2*u(4)*u(2))/(u(1)+u(2)+u(3)))-((2.6*u(4)*u(3))/(u(1)+u(2)+u(3)))-1.2*u(4);
s5=((0.2*u(4)*u(2))/(u(1)+u(2)+u(3)))+((2.6*u(4)*u(3))/(u(1)+u(2)+u(3)))-1.2*u(5);
s = [s1;s2;s3;s4;s5];
% --------------------------------------------------------------
function u0= chagastwic(x);
u0 = (heaviside(x+2)-heaviside(x-2))*ones(5,1);
% --------------------------------------------------------------
function [pl,ql,pr,qr] = chagastwbc(xl,ul,xr,ur,t)
pl = [0;0;0;0;0];
ql = [1;1;1;1;1];
pr = [0;0;0;0;0];
qr = [1;1;1;1;1];
The full error massage is:
Warning: Failure at t=1.000000e+00. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (3.552714e-15) at time t. > In ode15s at 668 In pdepe at 289 In chagastw at 21 Warning: Time integration has failed. Solution is available at requested time points up to t=1.000000e+00. > In pdepe at 303 In chagastw at 21 Error using surf (line 78) Z must be a matrix, not a scalar or vector
Error in chagastw (line 31) surf(x,t,u2)
4 commentaires
AHUOD ALSHERI
le 27 Sep 2018
Torsten
le 27 Sep 2018
You divide by u(1)+u(2)+u(3) which is zero at certain x-values.
AHUOD ALSHERI
le 27 Sep 2018
Réponses (0)
Catégories
En savoir plus sur Eigenvalue Problems dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!