How to hold different constellations using scatterhistogram?
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
Dear all,
I hope the title is explicit enough, does anyone have an idea?
Thanks in advance.
Best regards,
louis
Example of code:
% signal vector
X = rand(1,1e3)+1i*rand(1,1e3);
% power in signal
PX= mean(abs(X).^2);
% noise of variance power in signal/10
B = PX/10*(randn(1,1e3)+1i*randn(1,1e3));
% signal + noise
Y = X+B;
% plot
hold all
scatterhistogram(real(X),imag(X))
scatterhistogram(real(Y),imag(Y))
댓글 수: 0
채택된 답변
  Adam Danz
    
      
 2022년 7월 29일
        
      편집: Adam Danz
    
      
 2022년 7월 29일
  
      scatterhistogram produces a ScatterHistogramChart object within a figure.  When you call hold on, an axes is created if it doesn't already exist, and the axes is prepared to accept new objects.  scatterhistogram tells you that you cannot assign the ScatterHistogramChart object to the axes.  
Remove hold on so scatterhistogram can create the plot in a figure.  Scatterhistogram() is not set up to combine two ScatterHistogramChart objects within the same set of axes.  
댓글 수: 3
  Adam Danz
    
      
 2022년 8월 1일
				
      편집: Adam Danz
    
      
 2022년 8월 1일
  
			@Louis Tomczyk, you can, however, group your data together in a table and use a grouping variable to plot multiple sets of data into the same scatterhistogram chart.  There are some examples in the documentation:  scatterhistogram.
load patients
tbl = table(LastName,Diastolic,Systolic,Smoker)
s = scatterhistogram(tbl,'Diastolic','Systolic','GroupVariable','Smoker');
  Adam Danz
    
      
 2025년 4월 2일
				Alternatively,  you can append the existing data using set(__).  Here's a demo. 
x = randn(1,50)*2+9; 
y = randn(1,50)+5; 
s = scatterhistogram(x,y);
Append s with additional data and create a grouping variable g to identify which group each datapoint belongs to.  I created a new figure here for demonstration purposes.  
figure
s = scatterhistogram(x,y);
x2 = rand(1,40)+6;
y2 = rand(1,40)*2+4; 
g = [ones(numel(x),1); ones(numel(x2),1)+1];
set(s, 'XData', [x,x2], 'YData', [y,y2], 'GroupData', g);
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Polar Plots에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





