The module "screed" of the Mastrave modelling library
Copyright and license notice of the function screed
Copyright © 2007,2008,2009 Daniele de Rigo The file screed.m is part of Mastrave. Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Mastrave. If not, see http://www.gnu.org/licenses/.
Function declaration
Copyright (C)
Description
2007,2008,2009 Daniele de Rigo This file is part of Mastrave. Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Mastrave. If not, see <http://www.gnu.org/licenses/>. --------------------------------------------------------------------------- [ screeded_vals , valley_set ] = screed( vals, threshold, method ) Given a matrix vals and a threshold , the values of vals around the minimum are located as the valley_set according to one of the allowed method s that use threshold to.
Input arguments
vals ::numeric:: scalar, vector or matrix of numeric values threshold ::nonnegative:: non negative scalar or 2-dimensional vector method ::cellstring:: method to be used to locate the valley_set and to connect the valley set with the subset Uvals of untouched vals . Follows here a list of the implemented method s (it can be passed in method only one method for each set): normalization methods │ meaning ─────────────────────────┼─────────────────────────────────────────── 'lin' │ linear mapping where │ min(vals(:)) -> 0 │ max(vals(:)) -> 1 ─────────────────────────┼─────────────────────────────────────────── 'lin-m' │ linear mapping where │ min(vals(:)) -> 0 │ max(vals) -> 1 (one for each column) ─────────────────────────┼─────────────────────────────────────────── 'log' │ logarithmic mapping where │ min(vals(:)) -> 0 │ max(vals(:)) -> 1 ─────────────────────────┼─────────────────────────────────────────── 'log-m' │ logarithmic mapping where │ min(vals(:)) -> 0 │ max(vals) -> 1 (one for each column) ─────────────────────────┼─────────────────────────────────────────── connection methods │ meaning ─────────────────────────┼─────────────────────────────────────────── 'slide' │ connects valley_set with Uvals using a │ curve having the 1st derivative -> inf │ near valley_set and the same as that of │ Uvals when the curve is near Uvals ─────────────────────────┼─────────────────────────────────────────── 'spline1' │ connects valley_set with Uvals using a │ curve that linearly stretches the subset │ of vals between valley_set and Uvals ─────────────────────────┼─────────────────────────────────────────── 'spline3' │ connects valley_set with Uvals using a │ C1 differentiability class curve, i.e. a │ cubic stretching of the subset of vals │ between valley_set and Uvals ─────────────────────────┼─────────────────────────────────────────── 'spline5' │ connects valley_set with Uvals using a │ C2 differentiability class curve, i.e. a │ quintic stretching of the subset of vals │ between valley_set and Uvals ─────────────────────────┼─────────────────────────────────────────── 'spline7' │ connects valley_set with Uvals using a │ C3 differentiability class curve, i.e. a │ septic stretching of the subset of vals │ between valley_set and Uvals ─────────────────────────┼─────────────────────────────────────────── 'spline9' │ connects valley_set with Uvals using a │ C4 differentiability class curve, i.e. a │ nonic stretching of the subset of vals │ between valley_set and Uvals ─────────────────────────┼───────────────────────────────────────────
Example of usage
dx = 0.01; x = 0:dx:3*pi; y = sin(x); y1 = screed( y , [.2 .4] ); figure(1); plot( x , [y;y1]' ) title( 'function and screed function' ) xd = mean( [ x(1:end-1) ; x(2:end) ] ); figure(2); plot( xd , diff([y;y1]')./dx ) title( 'derivative of function and screed function' ) method = { 'lin' , 'slide' } y1 = screed( y , [.2 .4] , method ); figure(3); plot( x , [y;y1]' ) title( 'function and screed function' ) xd = mean( [ x(1:end-1) ; x(2:end) ] ); figure(4); plot( xd , diff([y;y1]')./dx ) title( 'derivative of function and screed function' ) method = { 'log' , 'spline5' } y1 = screed( y , [.2 .4] , method ); figure(5); plot( x , [y;y1]' ) title( 'function and screed function' ) xd = mean( [ x(1:end-1) ; x(2:end) ] ); figure(6); plot( xd , diff([y;y1]')./dx ) title( 'derivative of function and screed function' ) method = { 'log' , 'spline9' } y1 = screed( y , [.2 .4] , method ); figure(6); plot( x , [y;y1]' ) title( 'function and screed function' ) xd = mean( [ x(1:end-1) ; x(2:end) ] ); figure(7); plot( xd , diff([y;y1]')./dx ) title( 'derivative of function and screed function' )
version: 0.3.7
Support
The Mastrave modelling library is committed to provide reusable and general - but also robust and scalable - modules for research modellers dealing with computational science. You can help the Mastrave project by providing feedbacks on unexpected behaviours of this module. Despite all efforts, all of us - either developers or users - (should) know that errors are unavoidable. However, the free software paradigm successfully highlights that scientific knowledge freedom also implies an impressive opportunity for collectively evolve the tools and ideas upon which our daily work is based. Reporting a problem that you found using Mastrave may help the developer team to find a possible bug. Please, be aware that Mastrave is entirely based on voluntary efforts: in order for your help to be as effective as possible, please read carefully the section on reporting problems. Thank you for your collaboration.