Solving $y'' + n^2 y = 0 $ with boundary conditions

63 Views Asked by At

I'm trying to solve the following

$$y'' + n^2 y = 0$$ with $y(0)=y(H) = 0$

This should return $y(x) = \sin(2n\pi * x/H)$

However, in MATLAB it simply returns zero.

My code is

syms y(x) H n 

ode2 = diff(y,x,2) + n^2*y == 0 ;


 cond1 = y(0) == 0 ;


 cond2 = y(H) == 0 ;

 cond = [cond1 cond2];

 dsolve(ode2, cond)

This seems like a simple enough problem to solve, I just odn't know where I'm going wrong. Any help greatly appreciated.