plotting multiple histograms from data saved as double
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
hey guys..
I am trying to get 30 subplots with each 3 (differently coloured) histograms from column 1:3 of each row of the attached dataset saved as double.
tried hist but this wouldnt let me change the colour....histogram didnt work with double/cell array i think.
I am new to matlab...anyone could help? using matlab 2019b.
thanks!
採用された回答
Ameer Hamza
2020 年 4 月 3 日
編集済み: Ameer Hamza
2020 年 4 月 3 日
There are 29 rows in the cell array you attached.
colors = [1 0 0;
0 1 0;
0 0 1];
fig = figure();
ax = gobjects(1, 30);
for i = 1:size(P_RTpertrial,1)
ax(i) = subplot(10,3,i);
hold(ax(i));
for j = 1:size(M, 2)
histogram(P_RTpertrial{i,j}, 'FaceColor', colors(j,:), 'FaceAlpha', 0.3);
end
end
fig.WindowState = 'maximized';

10 件のコメント
Steffi
2020 年 4 月 3 日
hey thanks a lot for your answer...
hmmm unfortunately I get an error code "Error using histogram, Too many input arguments."
also I wonder...they should all look different...
is it ...
M = [P_RTpertrial{i,:}]; ?
but even then I get an error in the histogram line...(see above)
grrrr
Yes, you are correct. It should have been
M = [P_RTpertrial{i,:}];
but this won't work because matrices have a different number of rows. I have updated the code, try it now.
Steffi
2020 年 4 月 3 日
I have now also replace M with P_RTpertrial....but I still get "Error using histogram, Too many input arguments." when I get to the "histogram"-line. :(
Can you show the output of
which histogram
shows me the path to the following file:
function [result,descriptor]=histogram(x,descriptor)
% HISTOGRAM Computes the frequency histogram of the row vector x.
% [RESULT,DESCRIPTOR] = HISTOGRAM(X) or
% [RESULT,DESCRIPTOR] = HISTOGRAM(X,DESCRIPTOR) or
%where
% DESCRIPTOR = [LOWER,UPPER,NCELL]
%
% RESULT : A row vector containing the histogram
% DESCRIPTOR: The used descriptor
%
% X : The row vector be analyzed
% DESCRIPTOR: The descriptor of the histogram
% LOWER : The lowerbound of the histogram
% UPPER : The upperbound of the histogram
% NCELL : The number of cells of the histogram
%
% See also: http://www.cs.rug.nl/~rudy/matlab/
% R. Moddemeijer
% Copyright (c) by R. Moddemeijer
% $Revision: 1.2 $ $Date: 2001/02/05 09:54:29 $
if nargin <1
disp('Usage: RESULT = HISTOGRAM(X)')
disp(' RESULT = HISTOGRAM(X,DESCRIPTOR)')
disp('Where: DESCRIPTOR = [LOWER,UPPER,NCELL]')
return
end
% Some initial tests on the input arguments
[NRowX,NColX]=size(x);
if NRowX~=1
error('Invalid dimension of X');
end;
if nargin>2
error('Too many arguments');
end;
if nargin==1
minx=min(x);
maxx=max(x);
delta=(maxx-minx)/(length(x)-1);
ncell=ceil(sqrt(length(x)));
descriptor=[minx-delta/2,maxx+delta/2,ncell];
end;
lower=descriptor(1);
upper=descriptor(2);
ncell=descriptor(3);
if ncell<1
error('Invalid number of cells')
end;
if upper<=lower
error('Invalid bounds')
end;
result(1:ncell)=0;
y=round( (x-lower)/(upper-lower)*ncell + 1/2 );
for n=1:NColX
index=y(n);
if index >= 1 & index<=ncell
result(index)=result(index)+1;
end;
end;
Ameer Hamza
2020 年 4 月 3 日
This doesn't seem like the file provided by MATLAB. Have you placed some other function named histogram in MATLAB's path?
Steffi
2020 年 4 月 3 日
got this version from my colleauges...have looked online to download the original version....but didnt find anything...do you know where to best get it?
Ameer Hamza
2020 年 4 月 3 日
You cannot get it online. This only comes with the installation of MATLAB. Does the path shows that it lies somewhere like
C:\....\MATLAB\toolbox\....
or the file is placed somewhere else?
Steffi
2020 年 4 月 3 日
just downloaded new matlab version including toolbox and it works perfectly well now!
thanks a million!
Ameer Hamza
2020 年 4 月 3 日
Glad to be of help.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Distribution Plots についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
