Code covered by the BSD License  

Highlights from
Digital Karma: State Graphing

image thumbnail
from Digital Karma: State Graphing by Aman Siddiqi
Evolutionary Simulation, Interaction Graph

byte_selection.m
% The mousepoint is the top left point of the base conversion area in the
% top plane.

if ((dimension==1) & (0<currentgraphx) & (currentgraphx<=columnsshown) & (1<=currentgraphy) & (currentgraphy<=rows) & (currenty>=1))...
        | ((dimension==2) & (0<currentgraphx) & (currentgraphx<=columnsshown) & (0<currentgraphy) & (currentgraphy<=rowsshown));
    bytedimension=get(findobj('Tag','byteinput'),'string');
    baseconversionworked=1;
    if strcmp(bytedimension,'row');
        byteselection=a(currenty,:);
        byteoriginrow=currenty; byteendrow=currenty; byteorigincol=1; byteendcol=columns; byteoriginplane=currentlayer; byteendplane=currentlayer;
    elseif strcmp(bytedimension,'col');
        byteselection=a(:,currentx);
        byteoriginrow=1; byteorigincol=currentx; byteendcol=currentx; byteoriginplane=currentlayer; byteendplane=currentlayer;
        if dimension==1; byteendrow=completediterations+1; else; byteendrow=totalrows; end
    elseif strcmp(bytedimension,'plane'); % Makes a pole through the planes down from a cell
        byteselection=a(currenty,currentx,:);
        byteoriginrow=currenty; byteendrow=currenty; byteorigincol=currentx; byteendcol=currentx; byteendplane=1; byteoriginplane=currentlayer;
    elseif isempty(str2num(bytedimension))==0;
        bytedimension=str2num(bytedimension);
        if length(bytedimension)==1;
            if currentx+bytedimension-1<=columns;
                byteselection=a(currenty,currentx:currentx+bytedimension-1);
                byteorigincol=currentx; byteendcol=currentx+bytedimension-1; byteoriginrow=currenty; byteendrow=currenty;
                byteoriginplane=currentlayer; byteendplane=currentlayer;
            else; clear byteselection; end;
        elseif length(bytedimension)==2;
            if currentx+bytedimension-1<=columns
                if (dimension==1 & currenty+bytedimension(1)-1<=completediterations+1) | (dimension==2 & currenty+bytedimension(1)-1<=totalrows);
                    byteselection=a(currenty:currenty+bytedimension(1)-1,currentx:currentx+bytedimension(2)-1,currentlayer);
                    byteoriginrow=currenty; byteendrow=currenty+bytedimension(1)-1; byteorigincol=currentx;
                    byteendcol=currentx+bytedimension(2)-1; byteoriginplane=currentlayer; byteendplane=currentlayer;
                else; clear byteselection; end;
            else; clear byteselection; end;
        elseif length(bytedimension)==3;
            if currentx+bytedimension-1<=columns
                if (dimension==1 & currenty+bytedimension(1)-1<=completediterations+1 & bytedimension(3)==1)...
                        | (dimension==2 & currenty+bytedimension(1)-1<=totalrows & currentlayer-bytedimension(3)+1>0);
                    byteselection=a(currenty:currenty+bytedimension(1)-1,currentx:currentx+bytedimension(2)-1,currentlayer-bytedimension(3)+1:currentlayer);
                    byteoriginrow=currenty; byteendrow=currenty+bytedimension(1)-1; byteorigincol=currentx;
                    byteendcol=currentx+bytedimension(2)-1; byteoriginplane=currentlayer-bytedimension(3)+1; byteendplane=currentlayer;
                else; clear byteselection; end;
            else; clear byteselection; end;
        end;            
    else;
        set(findobj('Tag','byteinput'),'string','row');
        byteselection=a(currenty,:);
        byteoriginrow=currenty; byteendrow=currenty; byteorigincol=1; byteendcol=columns; byteoriginplane=currentlayer; byteendplane=currentlayer;
    end;
    if exist('byteselection');
        if dimension==1; bytecoordinates=['[',num2str(byteoriginrow-1),',',num2str(byteorigincol),']--[',num2str(byteendrow-1),',',num2str(byteendcol),']'];
        elseif dimension==2; bytecoordinates=['[',num2str(byteoriginrow),',',num2str(byteorigincol),',',num2str(byteendplane-1),']--[',num2str(byteendrow),',',num2str(byteendcol),',',num2str(byteoriginplane-1),']']; end;
        if structurenumbersizelimit==1;
            [byteselectionstructurenumber, byteselectionstructurenumberstring]=structure_number(byteselection,'on');
        else; [byteselectionstructurenumber, byteselectionstructurenumberstring]=structure_number(byteselection); end
    end;
end;

Contact us at files@mathworks.com