plotting multiple histograms from data saved as double
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
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.
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;
This doesn't seem like the file provided by MATLAB. Have you placed some other function named histogram in MATLAB's path?
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?
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?
just downloaded new matlab version including toolbox and it works perfectly well now!
thanks a million!
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
