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

7 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 23 Juin 2020
セル配列の各要素に、2次元配列が格納されています。
それぞれの各要素ごとに contour 関数で描画したいのですが、for ループを使用せずに、cellfun 関数を使って描画する方法を教えてください。

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 23 Juin 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 プロット

Plus de réponses (0)

Catégories

En savoir plus sur グラフィックス オブジェクト dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!