How can solve Laplacian of a function with coefficients?

2 views (last 30 days)
Hi guys, I need to solve the gross pitaevskii equation using matlab, and I need to solve something like that:
where A and B are scalars, x and y are two matrix (m x m) created by meshgrid of two vectors of the same length (m), and \phi is another matrix of size m x m. I know that using del2 it's possible to compute.
.
If I use diff(\phi,2,1) and diff(\phi,2,2) to calculate by separated and respectivley, I get a matrix (m-2, m) and (m, m-2). After, I need to plot in 2D using pcolor. the problem is the size of the matrix x and Y are different from the size of psi, using diff. Also, using del2 I cant incorporate the coefficient A and B.
how can I resolve this, please! Thanks!
I will put and example of my problem below.
x = [1:10];
y = [1:10];
[X,Y] = meshgrid(x,y);
A = 2;
B = 4;
%Example of function, but in my problem, phi is a matrix generated by a N iterations of a loop,
%in others words phi is a random matrix with size length(x) times length(y).
phi = exp(X+Y);
%using diff to calculate phi
psi_1 = A*diff(phi,2,1) +B*diff(phi,2,2);
%using del2
psi_2 = 4*del2(phi,x,y); % the problem here is that I don't know how to introduce the coefficients A and B into the laplacian!
figure(1)
subplot(1,2,1)
pcolor(X,Y,psi_1); shading interp
subplot(1,2,2)
pcolor(X,Y,psi_2); shading interp
Any help I will appreciate it.
Thanks!!!!

Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!