function rw(bands)

    freqs = [];
    bands = sort(bands);
    for i = 1:size(bands,2)
        freqs = [freqs ; mapBand(bands(i))];
    end
    lowest = freqs(size(bands,2));
    hold on
    grid
    for i = 1:size(freqs, 1)
        % printf('i = %d: min = %f, max = %f\n', i, freqs(i,1), freqs(i,2))
        badLengths(freqs(i, 1), freqs(i, 2), lowest)
    end
    hold off
end

function minMax = mapBand(band)
    switch band
        case 160
            minMax = [1800 2000];
        case 80
            minMax = [3500, 4000];
        case 60
            minMax = [5330.5, 5405];
        case 40
            minMax = [7000, 7300];
        case 30
            minMax = [10100, 10150];
        case 20
            minMax = [14000, 14350];
        case 17
            minMax = [18068, 18168];
        case 15
            minMax = [21000, 21450];
        case 12
            minMax = [24890, 24990];
        case 10
            minMax = [28000, 29700];
        case 6
            minMax = [50000, 54000];
        otherwise
            disp('Unexpected amateur band: ', band, ' m')
            minMax = [];
    end 
end

function badLengths(min_kHz, max_kHz, lowest_kHz)

	halfWave_ft = 468 / (lowest_kHz * 1e-3); % Max wavelength in band.
	qtrWave_ft = halfWave_ft / 2;
    
    % Plot length of zero feet through quarter wave, since antenna
    % must (should) be at least 1/4 wavelength long.
    qtrX = [0 0 qtrWave_ft qtrWave_ft];
    qtrY = [0 1 1          0];
    area(qtrX, qtrY);
    
    n = 1;
    while 1
        % For each min/max frequency delimiting a range, draw a rectangle
        % indicating bad, or very high impedance, end-fed wire lengths.
        lambda0_ft = n * 468 / (max_kHz * 1e-3);
        lambda1_ft = n * 468 / (min_kHz * 1e-3);
        badX = [lambda0_ft lambda0_ft lambda1_ft lambda1_ft];
        badY = [0          1          1          0];
        area(badX, badY);
        n = n + 1;
        if lambda1_ft > halfWave_ft
            break
        end
    end
end
