2016-06-15 6 views
0

Matlabの:このコードでは、同じ軸でプロット2と4 3Dガウス

x=linspace(-3,3,25); 
y=x';    
[X,Y]=meshgrid(x,y); 
z=exp(-(X.^2+Y.^2)/2); 
h=surf(x,y,z);shading interp 
%colormap(col4); 
set(h,'LineStyle', '-','LineWidth',0.001,'EdgeColor','k'); 
set(gca, 'YTick',[],'XTick',[],'ZTick',[]); 
box on 

私は、単一の3Dガウスプロットすることができます:私は今

1をプロットしたい enter image description here

を)これらの2つは同じ軸の中で隣り合っている

2)これらのうち2つは同じ軸の2列に2つ

基本的には、複数のガウス分布を持つ単一の3次元プロットが必要です。それが意味をなされるならば、個々のガウス分布の複数のプロットではなく

...これはおそらくかなり単純ですが、私は困惑しています。どんな助けでも大歓迎です。

この

は、私はむしろ、複数のサブプロットよりも、同じプロット上に複数のを望んでいることを明確にするために編集された

2ガウスバージョンの安っぽいモックアップは、次のようになります。 enter image description here

+1

subplot? (あなたは[MathWorks社のMATLABを使用して1つのウィンドウに複数のグラフをプロットする]の –

+1

が重複する可能性が何をしたいということですhttp://stackoverflow.com/questions/26233064/plotting-multiple-graphs-in-a-single-window-by- matlabを使用して) – Suever

+0

謝罪、十分正確ではなかった - 複数のプロットではなく、複数のプロットを同じ軸にプロットすることを望んでいます。 – user3519116

答えて

2

トリックがrepmatを使用してXY行列複製するだけである:、同じ面に2つのガウス分布については

x=linspace(-3,3,25); 
y=x';    
[X,Y]=meshgrid(x,y); 

X = repmat(X, 2, 2); 
Y = repmat(Y, 2, 2); 

z=exp(-(X.^2+Y.^2)/2); 

% note I'm using a different X and Y now in the call to surf() 
h=surf(1:size(z,1),1:size(z,2),z); 

shading interp 
%colormap(col4); 
set(h,'LineStyle', '-','LineWidth',0.001,'EdgeColor','k'); 
set(gca, 'YTick',[],'XTick',[],'ZTick',[]); 
box on 

X = repmat(X, 2, 1)を使用、またはそれ以上のため、repmat(X, n, k)

+1

これはまさに私が欲しかったものです。そんなにありがとう! – user3519116

+1

'' X''と '' Y''ではなく 'z'を複製することで少し最適化できると思いますが、全体的にはとても良いです! –

1

からMATLABドキュメント、@Anderにより示唆されるように必要な正確に何であるように思わサブプロット例:結果

x = 0:0.1:10; 
y1 = sin(2*x); 
y2 = cos(2*x); 

figure 
subplot(2,2,1)  % add first plot in 2 x 2 grid 
plot(x,y1)   % line plot 
title('Subplot 1') 

subplot(2,2,2)  % add second plot in 2 x 2 grid 
scatter(x,y2)  % scatter plot 
title('Subplot 2') 

subplot(2,2,3)  % add third plot in 2 x 2 grid 
stem(x,y1)   % stem plot 
title('Subplot 3') 

subplot(2,2,4)  % add fourth plot in 2 x 2 grid 
yyaxis left   % plot against left y-axis 
plot(x,y1) 
yyaxis right   % plot against right y-axis 
plot(x,y2) 
title('Subplot 4') 

sの中:

enter image description here

+0

私はこれがあなたが必要としていると思う、そうでなければ1つのグラフに複数の線をプロットしようとする: 'plot(x、y1、x、y2)' –

+0

あなたの答えと不正確さについてのお詫びに感謝します.-私は基本的に同じプロットそれが意味をなすならば、複数のプロットよりもむしろ? – user3519116

関連する問題