2012-07-01 64 views

回答

2

首先你需要有數據用於製作圖;如果你直接擁有它們,那就是簡單的例子。

%# make sure the plot is the current axes object by clicking on it 
%# or else use the actual axes handle instead of gca 
X = get(gca,'xdata'); 
Y = get(gca,'ydata'); 
Z = get(gca,'zdata'); 

下一頁:如果沒有 - - 例如,如果你有一些其他的劇本情節,或由其他人,你只是加載保存體形文件,你可以從圖中這樣得到的數據,使用邏輯索引:

index = Z > 0; 
X_of_interest = X(index); 
Y_of_interest = Y(index); 
Z_of_interest = Z(index); 

新的變量包含的所有點,其中條件Z>0是真實的X,Y,Z值。

+0

將這4行添加到我的代碼後,MATLAB給了我這個錯誤:'未定義的函數或變量Z'。 – user559096

+0

你需要用你的代碼中調用的變量來替換'''','''''Z'。 – tmpearce