1

「データ」と呼ばれるフィールドを持つこのmatlabファイルがあります。「データ」には、さまざまな結合(x5Q12など)のフィールドがたくさんあります。 ここに画像の説明を入力

各フィールドから 1 つの列を含む 1 つのボックス プロット (つまり、36 個のボックスを含むボックス ダイアグラム) を作成しようとしています。私はこのコードを試しました (例えば、すべての結合の列 2 のボックスをプロットするために) が、うまくいきません:

boxplot(gilts_withoutdates.data.:(:,2));figure(gcf);

ここでは、構造内のさまざまなレベルを呼び出すという私の理解が問題であることを知っています。何か提案はありますか?どうもありがとう。

4

2 に答える 2

2

STRUCTFUNを使用して、構造体のすべてのフィールドの特定の列からデータを抽出できます。

col2plot = 2; %# this is the column you want to plot

%# return, for each field in the structure, the specified
%# column in a cell array
data2plot = structfun(@(x){x(:,col2plot)},gilts_withoutdates.data);

%# convert the cell array into a vector plus group indices
groupIdx = arrayfun(@(x)x*ones(size(data2plot{x})),1:length(data2plot),'uni',0);
groupIdx = cat(1,groupIdx{:});
data2plot = cat(1,data2plot{:});

%# create a compact boxplot
boxplot(data2plot,groupIdx,'plotStyle','compact','labels',labels)

データの分散に興味がある場合は、関数distributionPlotをお勧めします。

于 2012-08-12T04:18:41.983 に答える
0
B=gilts_withoutdates.data;
b=fieldnames(B);
for a=1:numel(b)
  boxplot(B.(b{a})); fig;
end

各フィールドの5列のデータごとに箱ひげ図をプロットするには、次のようにします。

   pos=1;
   for i = 1:numel(b)
    for ii=1:5
       subplot(numel(b),5,pos);boxplot(B.(b{i})(:,ii));pos=pos+1;
    end
   end
于 2012-08-11T19:08:36.697 に答える