필터 지우기
필터 지우기

I have two plots, I want to take the difference between two plots using histogram function. how can I take difference using both x and y axis

조회 수: 4 (최근 30일)
I have two plot, I want to take the difference between two plots using histogram function. how can I take difference using both x and y axis

답변 (1개)

Khalid Mahmood
Khalid Mahmood 2021년 4월 17일
편집: Khalid Mahmood 2021년 4월 17일
I have created an example for 1D histogram (histogram using single vector), histogram2 (2D histogram using 2 vectors), imhist(histogram of 2d or 3D images). Data and histograms have been plotted. In case of image, imshow is used to show image (not plot function) and imhist is used (not histograms2).
close all, clear all
a=randi(225,1,500)+30; %1x500 random integers between 30 and 255
b=randi(225,1,500); %1x500 random in tegers between 0 and 255
subplot(2,3,1);plot(a,'r+');
hold on;
plot(b, 'go');title(' 1D Data a (red) and b(green)')
subplot(232);
%plot(hist(a),'r--+');hold on
histogram(a,10,'EdgeColor','red'); %10 bins
hold on
histogram(b,10,'EdgeColor','green'); %10 bins, green edges
title('1D hostogram of a (red) and b(green)')
subplot(233);h=histogram2(a,b,10);title('2D hostogram using both x and y, 10 bins')
h.EdgeColor='yellow'; %can change properties if handle is known
%c=randi(220,500)+30; %500x500 matrix of random numbers, not good for
%histogram
c=imread('peppers.png'); %image is best for 2d or 3d matrix histogram
subplot(234);imshow(c);
subplot(235);imhist(c); axis tight
hold off

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by