view +blockmatrix/getDivision.m @ 577:e45c9b56d50d feature/grids

Add an Empty grid class The need turned up for the flexural code when we may or may not have a grid for the open water and want to plot that solution. In case there is no open water we need an empty grid to plot the empty gridfunction against to avoid errors.
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 07 Sep 2017 09:16:12 +0200
parents f0ef314e2070
children a5f1b0267dba
line wrap: on
line source

function div = getDivision(bm)
    if ~blockmatrix.isBlockmatrix(bm)
        error('blockmatrix:getDivision:NotABlockmatrix', 'Input is not a blockmatrix');
    end

    if isempty(bm)
        div = {[],[]};
        return
    end

    div = {row_height(bm),col_width(bm)};
end


function m = col_width(C)
    m = zeros(1,size(C,2));
    for j = 1:size(C,2)
        for i = 1:size(C,1)
            if isempty(C{i,j})
                continue
            end
            m(j) = size(C{i,j},2);
        end
    end
end

function n = row_height(C)
    n = zeros(1,size(C,1));
    for i = 1:size(C,1)
        for j = 1:size(C,2)
            if isempty(C{i,j})
                continue
            end
            n(i) = size(C{i,j},1);
        end
    end
end