フィルターのクリア

How to set the lower bound of extrapolation?

13 ビュー (過去 30 日間)
George McFadden
George McFadden 2012 年 7 月 16 日
コメント済み: charles alexander 2021 年 7 月 29 日
Hi!
Is it possible to set a lower bound for extrapolating using the interp2 function? I am dealing with nitrogen concentrations, and a negative concentration cannot exist. However, currently the extrapolation results have negative values. So I do not want the extrapolation to go less than 0. I do not desire to set an upperbound limit.
Thanks! George
  3 件のコメント
George McFadden
George McFadden 2012 年 10 月 30 日
The interpolation and extrapolation are both producing below 0 values. Thanks!
charles alexander
charles alexander 2021 年 7 月 29 日
yes, its is possible to set a lower bound.
you will need to find the value of c from the linear discriminant model.
extrapolating will be (c1+c2)/100*values less than 30,
find the percentage value of extrapolation, add the (percentage value to the value of extrapolation:c3).
(c1+c2)/c3*fill_value.

サインインしてコメントする。

採用された回答

D G
D G 2012 年 7 月 16 日
You could set the boundary limit manually after the calculation like this.
concentration(concentration < 0) = 0;
I create a function that does just this.
function value = clip(value, clip, type)
%CLIP Clip values
% Adjust values in a vector such that no value extends beyond the
% specified type.
%
% Inputs:
% Clip min and max together:
% value (vector - 1 by x)
% clip (vector - 1 by x > 1)
% Clip min and max seperately
% value (vector - 1 by x)
% clip (scalar)
% type (char - min/max)
%
% Outputs:
% value - The clipped values
if length(clip) > 1
value(max(clip) < value) = max(clip);
value(value < min(clip)) = min(clip);
else
switch lower(type)
case 'min'
value(value < clip) = clip;
case 'max'
value(clip < value) = clip;
end %switch
end
end %clip
And you can use it like this.
concentration = clip(concentration, 0, 'min');
But it is more useful when you want to clip on both ends of the spectrum.
concentration = clip(concentration, [0, 100]);
If you have more than 2 values in the boundary, it choose the min and max as the clipping boundaries.
  2 件のコメント
Walter Roberson
Walter Roberson 2012 年 7 月 17 日
concentration(concentration < 0) = 0;
can also be formulated as
concentration = max(0, concentration);
D G
D G 2012 年 7 月 17 日
編集済み: D G 2012 年 7 月 17 日
So it can, hilarious! It seems a little backwards. Why wouldn't that be min, and the reverse be max?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation of 2-D Selections in 3-D Grids についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by