% Create a color for visualizing conductivity value inside a finite
% difference grid.
%
% Arguments:
% cond      value of the conductivity
% condmin   minimum of the conductivity scale
% condmax   maximum of the conductivity scale
%
% Returns:
% color     RGB color as a three-vector with entries in range [0,1]
%
% Samuli Siltanen May 2025

function color = colorscale_cond_scaled(cond,condmin,condmax)

% Check validity of the request
if (cond<condmin)|(cond>condmax)
    error('Conductivity value out of range')
end
if condmax<0
    error('Maximal conductivity condmax must be positive')
end

% Extreme colors
color_condmin = [.5 .6 .5]; % Color of minimal conductivity
color_condmax = [.8 .9 .8]; % Color of maximal conductivity

% Calculate appropriate color
color = color_condmin + ((cond-condmin)/(condmax-condmin))*(color_condmax-color_condmin);


