
How can I plot this solution to Laplace's equation?
9 views (last 30 days)
Show older comments
I have this solution to Laplace's equation with specific boundary conditions (not necessary for question)

I am trying to plot this in 3D with the code:
x=0:.01:3;
y=0:.01:2;
[X, Y]=meshgrid(x, y);
uxy=zeros(size(X));
for n=1:20
cn=(8*sin(n*pi/2))/(n^2*pi^2*sinh(3*n*pi/2));
uxy=uxy+cn*sinh(n*pi*x/2).*sin(n*pi*y/2);
end
surf(X, Y, uxy)
It keeps telling me that my inner matrix dimensions must agree yet I cannot figure out how to fix this. If you could help me plot this, that would be great. Thanks!
0 Comments
Accepted Answer
Ameer Hamza
on 24 May 2018
This error occurs when two matrices being multiplied does not have consistent dimensions. In your case you put variables x and y, when you actually need to write X and Y. Try this
uxy=uxy+cn*sinh(n*pi*X/2).*sin(n*pi*Y/2);

0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!