Problem with PDE resolution
Show older comments
I get this error message when running my script PDEsol.m
>> PDEsol
Error using /
Matrix dimensions must agree.
Error in pdefun (line 13)
s = [dudx(2)-alpha*u(1)*u(2)*(1/(1-(u(1)/c)*(dudx(2))^(-1)));0];
Error in pdepe (line 246)
[c,f,s] = feval(pde,xi(1),t(1),U,Ux,varargin{:});
Error in PDEsol (line 10)
sol = pdepe(m,@pdefun,@pdeic,@pdebc,x,t)
This is myscript PDEsol.m :
%%
%select spatial and temporal mesh
%x = [0 0.005 0.01 0.05 0.1 0.2 0.5 0.7 0.9 0.95 0.99 0.995 1];
%t = [0 0.005 0.01 0.05 0.1 0.5 1 1.5 2];
x=[0:0.05:1];
t=[0:0.05:0.717];
%%
%solve PDEs system
m = 0;
sol = pdepe(m,@pdefun,@pdeic,@pdebc,x,t);
%%
%extract PDEs solutions
u1 = sol(:,:,1);
u2 = sol(:,:,1);
%%
%pressure oscillation's plot
surf(x,t,u2)
title('Pressure oscillations [Pa]')
xlabel('Distance x [m]')
ylabel('Time t [s]')
Below are the function call by PDEsol.m :
%PDEs system
function [c,f,s] = pdefun(x,t,u,dudx)
%
epsilon=1;
b=1;
c=200;
rho=1.22;
beta=b/(2*(c^3)*rho);
alpha=epsilon/(rho*(c^3));
%
c = [beta*((1/(1-(u(1)/c)*(dudx(2))^(-1)))+u(1)/(c*(1-(u(1)/c)*(dudx(2))^(-1))^2));1];
f = [0;0];
s = [dudx(2)-alpha*u(1)*u(2)*(1/(1-(u(1)/c)*(dudx(2))^(-1)));0];
end
%
%
%initial condition
function u0 = pdeic(x)
u0 = [sin(x);sin(x)];
end
%
%
%boundary condition
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,t)
pl = [ul(1); ul(2)];
ql = [0; 0];
pr = [ur(1)-0.9; ur(2)-0.9];
qr = [0; 0];
end
Accepted Answer
More Answers (0)
Categories
Find more on Boundary Conditions 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!