Matlab hyperbolic PDE equation errors
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello people,
I am trying to solve a hyperbolic PDE and as a kickstart, I am using a code from matlab documentation but changing few parameters. However I am getting errors, which I cannot resolve. Basically I am solving a wave equation as given in matlab documentation but changing parameters f (forcing term) and a. Here is code:
clear all;
clc;
close all;
[p,e,t]=initmesh('squareg');
x=p(1,:)';
y=p(2,:)';
u0=sin(x);
ut0=cos(y);
n=31;
tlist=linspace(0,5,31);
a=cos(y); %GETTING ERROR HERE
f=sin(x); %GETTING ERROR HERE ALSO
uu=hyperbolic(u0,ut0,tlist,'squareb3',p,e,t,1,a,f,1);
figure; set(gcf,'renderer','zbuffer');
delta=-1:0.1:1;
[uxy,tn,a2,a3]=tri2grid(p,t,uu(:,1),delta,delta);
gp=[tn;a2;a3];
newplot;
umax=max(max(uu));
umin=min(min(uu));
for i=1:n
pdeplot(p,e,t,'xydata',uu(:,i),'zdata',uu(:,i),'zstyle','continuous',...
'mesh','off','xygrid','on','gridparam',gp,'colorbar','off');
axis([-1 1 -1 1 umin umax]); caxis([umin umax]);
M(i)=getframe;
end
movie(M,1);
I am not getting where I am making mistake in writing f and possibly a. Can someone comment? Thanks in advance!
0 Commenti
Risposte (1)
Bill Greene
il 15 Mag 2014
There are several ways to define PDE Toolbox coefficients that vary spatially. But, defining the value of the coefficient at every node point, as in the lines where you are getting errors, is not one of them.
One way to define simple coefficients like in your example is simply to replace your two lines with these:
a = 'cos(y)';
f = 'sin(x)';
Defining coefficients as a string expression is documented here:
For more complicated coefficients, it is usually more convenient to define them using a MATLAB function. That approach is documented here:
Bill
Vedere anche
Categorie
Scopri di più su PDE Solvers in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!