cellfun 関数を使って、セル配列の各要素を別々のグラフとして表示するにはどうすればよいですか?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 23 Jun. 2020
Beantwortet: MathWorks Support Team
am 23 Jun. 2020
セル配列の各要素に、2次元配列が格納されています。
それぞれの各要素ごとに contour 関数で描画したいのですが、for ループを使用せずに、cellfun 関数を使って描画する方法を教えてください。
Akzeptierte Antwort
MathWorks Support Team
am 23 Jun. 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 プロット
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu グラフィックス オブジェクト finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!