The 'YDataSource' property is not available for histogram object and hence it not possible to link it directly with LINKDATA.
To work around this issue, use the BAR function, which can be used to plot a histogram, and specify the 'YDataSource' for a BAR object.
This approach will require:
1. Computing vectors n and xout containing the frequency counts and the bin locations with the following command:
[n,xout] = hist(ydata,xdata) ;
2. Using bar(xout,n) to plot the histogram. For more information on using HIST and BAR functions together, please see the HIST function documentation by executing the following in the MATLAB command prompt:
Consider the following example:
x = -4:0.1:4;
y = randn(1000,2);
[n,xout] = hist(y,x) ;
figure
subplot(2,1,1)
bar(xout,n(:,1),'YDataSource','n(:,1)')
subplot(2,1,2)
bar(xout,n(:,2),'YDataSource','n(:,2)')
linkdata on
y = randn(1000,2);
[n,xout] = hist(y,x) ;
Best Answer