image thumbnail
from MATLAB For Java Programmers by David Forstot
Demo files and presentation for live webinar recorded on 10/30/2007

viewData(YMatrix1)
function viewData(YMatrix1)
%VIEWDATA(YMATRIX1)
%  YMATRIX1:  matrix of y data

% Copyright 2007 The MathWorks, Inc.
% This code is provided for example only.

% pause for display
pause(0.1);

% ensure Matrix is in proper orientation
[rows cols] = size(YMatrix1);
if (cols > rows) && (rows == 2)
    YMatrix1 = YMatrix1';
end

% Generate derrived data
brokenDelta1 = YMatrix1(:, 1) - YMatrix1(:, 2);

%  Auto-generated by MATLAB on 17-Oct-2007 16:47:02

% Create figure or re-use old one
figure1 = figure(1);
delete(get(gcf,'Children'));

% Create subplot
subplot1 = subplot(2,1,1,'Parent',figure1);
box('on');
hold('all');

% Fix Y axis limits
ylim([-0.25 0.25]);

% Create multiple lines using matrix input to plot
plot1 = plot(YMatrix1,'Parent',subplot1);
set(plot1(1),'DisplayName','Left');
set(plot1(2),'DisplayName','Right');

% Create xlabel
xlabel('Sample');

% Create ylabel
ylabel('Amplitude');

% Create title
title('Stereo Signal');

% Create subplot
subplot2 = subplot(2,1,2,'Parent',figure1);
box('on');
hold('all');

% Fix Y axis limits
ylim([-0.25 0.25]);

% Create title
title('Difference');

% Create xlabel
xlabel('Sample');

% Create ylabel
ylabel('Amplitude');

% Create plot
plot(brokenDelta1,'Parent',subplot2,'DisplayName','brokenDelta');

% Link Axes
 linkaxes([subplot1 subplot2],'x');

Contact us at files@mathworks.com