Rank: 208519 based on 0 downloads (last 30 days) and 0 files submitted
photo

Romesh

E-mail
Company/University
University of Sydney

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Romesh View all
Updated File Comments Rating
12 Feb 2012 FFT-based convolution Discrete convolution using FFT method Author: Bruno Luong

I think this says it all...

>> tic;C = convn(Vs,Vs);toc;
Elapsed time is 473.103412 seconds.
>> tic;C2 = convnfft(Vs,Vs);toc;
Elapsed time is 1.351315 seconds.
>> max(max(max(abs(C-C2))))
ans =
   5.2208e-15

Thanks so much for this!

02 Dec 2011 Making MATLAB Swing TabbedPanes, SplitPanes, SideBars, ScrollPanes etc for MATLAB Author: Malcolm Lidierth

Fantastic work. I'm also interested in the MCC, and successfully compiled the demo on Mac OS R2011a with only one issue:

Depfun error: 'Method 'getBackground' in class 'GSideBar' uses different access permissions than its super-class 'GTool'.'

The compiled code seems to run fine after I deleted this file. I ran waterloo.m before mcc. I guess I'll need to send some emails to work out exactly what constitutes a derivative work/whether including the source code for just the waterloo part of the project is sufficient (my current impression is that this would be acceptable...?)

09 May 2011 cloudPlot A function to plot the distribution of 2-dimensional data. Author: Daniel Armyr

Thanks for the update Daniel! However, the key change I made was in calling imagesc:

imagesc([axisLimits(1) axisLimits(2)],[axisLimits(3) axisLimits(4)],canvas_display');

If you provide imagesc with the axis limits, then you are able to completely do away with rescaling. Thus you don't need scale factors and you don't need to plot and record the original axes- much simpler!

04 May 2011 cloudPlot A function to plot the distribution of 2-dimensional data. Author: Daniel Armyr

Awesome code, I use it all the time and it is fantastic. However, there were a couple of things that are rough around the edges
- Different scaling means the resulting plot has different axis limits so it is hard to overlay data
- Cannot move the plot around using the drag tool
- Sometimes the limits are not what I expect (e.g. there are empty spaces on the plot because the plot is larger than the canvas- I get that this shouldn't happen in theory!)
- Cannot readily modify the number of bins to give a different plot resolution

I've made some changes that I think fix all of these problems (definitely NOT certified bug free though!), and I've also managed to remove the try-catch block because I think I've fixed the error condition that it was catching.

This code is a drop-in replacement for cloudPlot:

function [h,canvas] = cloudPlot(X,Y,axisLimits,useLogScale,bins)
% Display a cloud plot from X and Y data
%
% Only X and Y are mandatory arguments
% useLogScale = 1 to take the log of the data (to visalise data where
    % there are large variations in density)
% axisLimits = [x_min, x_max, y_min, y_max], [] to omit
% bins = [number_x_bins, number_y_bins] (defines resolution of output)
    %
    % e.g. cloudPlot(x,y,[],1,[500 500]) to produce a cloudPlot with
    % 500x500 bins, displaying the log of the density with automatic
    % axis limits
%
% By Romesh Abeysuriya, based heavily on cloudPlot.m by Daniel Armyr
    %
    % (from Daniel Armyr's cloudPlot.m):
    % A cloudplot is in essence a 2 dimensional histogram showing the
    % density distribution of the data described by X and Y.
    % As the plot displays density information, the
    % dimensionality of X and Y are ignored. The only requirement is that X and
    % Y have the same number of elements. Cloudplot is written to visualize
    % large quantities of data and is most appropriate for datasets of 10000
    % elements or more.

% Check the data size
assert (numel(X) == numel(Y),'The number of elements in X and Y must be the same');
if nargin < 4; useLogScale = false; end
    if nargin < 3 | isempty(axisLimits) % Calculate default axis limits
axisLimits = [min(X(:)) max(X(:)), min(Y(:)) max(Y(:))] ;
end

%Remove any nans or Infs in the data
pointSelect = isfinite(X) & isfinite(Y) & X >= axisLimits(1) & X <= axisLimits(2) & Y >= axisLimits(3) & Y <= axisLimits(4);
X = X(pointSelect);
Y = Y(pointSelect);

g = axes('Xlim',[axisLimits(1) axisLimits(2)],'Ylim',[axisLimits(3) axisLimits(4)],'units','pixels');
if nargin < 5 % Calculate the default number of pixels
plotsize = get(g,'Position');
bins = ceil(plotsize(3:4));
end
binSize(2) = diff(axisLimits(3:4))./(bins(2)-1);
binSize(1) = diff(axisLimits(1:2))./(bins(1)-1);
canvas = zeros(bins);

% Calculate bin indices for each of the points in the data arrays
xBinIndex = floor((X - axisLimits(1))/binSize(1))+1;
yBinIndex = floor((Y - axisLimits(3))/binSize(2))+1;

% Collect the indices
for i = 1:numel(xBinIndex);
canvas(xBinIndex(i),yBinIndex(i)) = canvas(xBinIndex(i),yBinIndex(i)) + 1;
end

% Postprocessing
    canvas_display = canvas; % Copy the canvas so we can make changes to the display
                    % without modifying the underlying data
    if useLogScale
canvas_display = log10(canvas_display);
    end
    %canvas_display = canvas_display > 0; % Show binary rather than graded data
%colormap gray % Use grayscale so background is black
%canvas_display = imcomplement(canvas_display); % Display a negative image

image_handle = imagesc([axisLimits(1) axisLimits(2)],[axisLimits(3) axisLimits(4)],canvas_display'); % Show the image
axis('xy') % Reverse the y-axis
set(g,'units','normalized' ); % Enable resizing

if nargout > 0
h = image_handle;
end

Contact us at files@mathworks.com