2
我想用Matlab來產生這個圖。內置的橢球功能令人困惑。對於這個問題,我有兩個變量(寬度和長度)和一個恆定的高度。如何從Matlab中的標量數據生成這個特定的3D圖形?
爲了讓它變得非常簡單我想說明,當我們接近尖端時,寬度是變化的,但高度是恆定的。 w,x,h是圖中顯示的變量。
我真的很感激,如果有人可以幫忙。
我想用Matlab來產生這個圖。內置的橢球功能令人困惑。對於這個問題,我有兩個變量(寬度和長度)和一個恆定的高度。如何從Matlab中的標量數據生成這個特定的3D圖形?
爲了讓它變得非常簡單我想說明,當我們接近尖端時,寬度是變化的,但高度是恆定的。 w,x,h是圖中顯示的變量。
我真的很感激,如果有人可以幫忙。
下面的代碼可以讓你很長的路要走,我想。見例如輸出:
我添加足夠多的意見,你應該能夠把它從這裏...
% plot ellipsoid in 3D
% height and width of ellipsoid:
e_h = 10;
e_w = 3;
% position where the "quivers" (arrows) go:
q_offset = 2; % distance from axis
q_scale = 0.5; % multiplier to give parabola some size
q_spacing = 0.5; % distance between arrows
q_height = 2.5; % height above XY plane where arrows are drawn
N = 1000; % number of points for drawing
theta = linspace(0, 2*pi, N); % parameter to help drawing ellipse
zerov = zeros(1, N); % array of zeros that I will need
% coordinates of main ellipse:
x = e_w * sin(theta);
y = zeros(size(x));
z = e_h * cos(theta);
% plot main ellipse:
figure;
plot3(x, y, z)
% secondary plot
y2 = q_scale*(e_w.^2 - x.^2) + 2; % offset parabola - what your plot looked like...
hold on
plot3(x, y2, zerov+q_height); % plotting the parabola in the XY plane at height
axis equal % make the plot dimensions isotropic
% add quivers
q_base = -e_w:q_spacing:e_w; % x coordinate; y and z are fixed
q_length = (e_w.^2 - q_base.^2)*q_scale; % length of quiver - just an equation I chose
q0 = zeros(size(q_base)); % another vector I will need multiple times
q1 = ones(size(q_base)); % ditto
% plot the arrows: the "-1" argument means "don't scale"
quiver3(q_base, q0+q_offset, q_height*q1, q0, q_length, q0, -1)
你試圖重現精確的圖表(包括箭頭)在Matlab - 有一定的維度變量?或者只是其中的一部分?你正在繪製的公式是什麼?這不是一個難題,但除非你非常清楚地指定,否則你不會喜歡答案... – Floris 2013-02-12 21:14:38