Data dimensions must agree error
Afficher commentaires plus anciens
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)
Réponses (1)
Walter Roberson
le 3 Août 2021
0 votes
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()
Catégories
En savoir plus sur Interpolation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!