Matlab hyperbolic PDE equation errors
1 次查看（过去 30 天）
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:
a=cos(y); %GETTING ERROR HERE
f=sin(x); %GETTING ERROR HERE ALSO
axis([-1 1 -1 1 umin umax]); caxis([umin umax]);
I am not getting where I am making mistake in writing f and possibly a. Can someone comment? Thanks in advance!
Bill Greene 2014-5-15
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: