Matlab hyperbolic PDE equation errors
2 views (last 30 days)
Show older comments
Commented: Amit Kumar on 15 May 2014
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 on 15 May 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:
Find more on Geometry and Mesh 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!