Data dimensions must agree error

1 visualización (últimos 30 días)
Soloman Thokala
Soloman Thokala el 3 de Ag. de 2021
Respondida: Walter Roberson el 3 de Ag. de 2021
This is the program I executed and it has thrown an error that data dimensions must agree.
X dimenion: 129 129 129
y dimension: 129 129 129
q dimension: 129 129 129
u0 dimension: 129 129.
Kindly help me.
% physical constants
m =1;
omega =1;
hbar =1;
% constants defining the Gaussian IC
a =4;
b =1;
% number of grid points ( total is N+1) and the grid
N =128;
z=linspace(-10,10,N +1);
[y,x,q]= meshgrid(z,z,z);
psi = @(q)(1/sqrt(2.*b.*sqrt(pi))).*(exp(-(q - a ).^2/(2.*b^2)));
s1=exp(-1i*q.*y);
s2=conj(psi(x+q/2));
s3=psi(x-q/2);
u0=trapz(z,s1.*s2.*s3,3);
figure(1)
clf
caxis([-0.1 ,0.1])
axis([-10 10 -10 10 -0.05 0.1])
colorbar ;
surf(x,y,u0)

Respuestas (1)

Walter Roberson
Walter Roberson el 3 de Ag. de 2021
x and y coordinates for surf() must be either vectors or 2 dimensional, never 3 dimensional.
If you have 3 independent variables and one result variable, then you cannot use surf()

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by