cellfun 関数を使って、セル配​列の各要素を別々のグ​ラフとして表示するに​はどうすればよいです​か?

7 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 23 de Jun. de 2020
Respondida: MathWorks Support Team el 23 de Jun. de 2020
セル配列の各要素に、2次元配列が格納されています。
それぞれの各要素ごとに contour 関数で描画したいのですが、for ループを使用せずに、cellfun 関数を使って描画する方法を教えてください。

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 23 de Jun. de 2020
例えば、1つの Figure 上に重ね書きを行いたい場合は、以下のように実行します。
% テスト用のデータを作成
C = cellfun(@(x)rand(10),cell(3),'UniformOutput',false);
figure
hold on
cellfun(@contour,C) % 各セルの要素に対して contour 関数を実行
また、subplot 関数を使って、別々の Axes に描画したい場合は、以下のように実行します。
[m,n] = size(C); % セル配列のサイズを取得
f = figure;
arrayfun(@(x)subplot(m,n,x),1:numel(C)); % subplot で Axes を作成
ax = flipud(findobj(f, 'Type','Axes')); % 描画順になるように反転
cellfun(@(ax,Z)contour(ax,Z),num2cell(ax),C(:)) % 各セル要素ごとにContour プロット

Más respuestas (0)

Categorías

Más información sobre グラフィックス オブジェクト en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!