以下是我的代码。我正在尝试用 3-D 绘制一些东西:
vp = 6000;
vs = 1.0e+03 .*[0.5000, 0.6094 , 0.7188 , 0.8281 , 0.9375 , 1.0469 , 1.1562 , 1.2656 , 1.3750 , 1.4844, 1.5938 , 1.7031 , 1.8125 , 1.9219 ,2.0312 , 2.1406,2.2500 , 2.3594 , 2.4688 , 2.5781 ,2.6875 ,2.7969 , 2.9062 , 3.0156 , 3.1250 , 3.2344 , 3.3438 , 3.4531 , 3.5625 , 3.6719 ,3.7812 ,3.8906];
% y= vp ./ vs;
y1= [12.0000,9.8462, 8.3478, 7.2453, 6.4000, 5.7313, 5.1892, 4.7407, 4.3636, 4.0421, 3.7647, 3.5229, 3.3103, 3.1220, 2.9538, 2.8029,2.6667 ,2.5430 ,2.4304 ,2.3273 ,2.2326 ,2.1453 , 2.0645 ,1.9896 ,1.9200 ,1.8551 ,1.7944 ,1.7376 ,1.6842 ,1.6340 ,1.5868 ,1.5422];
x = (0:0.2:2*pi); %# set a range for vale of x
[X, Y] = meshgrid(x, y);
p = sin(x);
theta= [0.0833, 0.1016, 0.1198, 0.1380 , 0.1562 , 0.1745 , 0.1927 , 0.2109 , 0.2292 , 0.2474 , 0.2656, 0.2839 , 0.3021 , 0.3203, 0.3385 , 0.3568, 0.3750, 0.3932, 0.4115, 0.4297 , 0.4479 , 0.4661 , 0.4844 , 0.5026 , 0.5208 , 0.5391 , 0.5573 , 0.5755 ,0.5938 , 0.6120 ,0.6302 , 0.6484];
curl = ((theta .^ 2) - ((vs .* p) .^ 2) ) .^ 0.5
R_o = (1-2*(vs.^2)) ;
k_o = (1 -2*(vs.^2)./(R_o));
R_pv = (2*curl.^(-1)).*(k_o).*((sin(x)).^2);
mesh(x,R_pv,y1)
问题在这里:
curl = ((theta .^ 2) - ((vs .* p) .^ 2) ) .^ 0.5;
我收到以下错误:
??? Error using ==> times
Matrix dimensions must agree.
Error in ==> project1_Rpv at 11
curl= ((theta .^ 2) - ((vs .* p) .^ 2) ) .^ 0.5;
尝试解决问题:
我有一种直觉,我弄乱了一些矩阵,但不确定在哪里。我确保我的矩阵是 1x1 并且长度相同。
编辑:感谢 Oli Charlesworth,我已经修复了vs
. 现在我收到以下错误:
??? Error using ==> mesh at 80
Z must be a matrix, not a scalar or vector.
Error in ==> project1_Rpv at 18
mesh(x, R_pv, y1) ## (x, y, z)
我所有的矩阵都是 1x1 但我仍然遇到错误。