Enter table with conditional limits and able to interpolate

I would like to enter the following numerical table with conditional limits and be able to interpolate within the values provided in the table. I was able to enter the rows x columns but I do not know what can I do for those values that are less than or larger than. How can <= or >= be taken care of? I believe interp2 should be used to find intermediate values for lets say h/L=12 degrees and h/L =0.35 for example. Please advise.

5 Comments

It would be easier for folks if you attached the data as a text file or just entered text rather than images that can't do anything with except retype..."Help us help you!"
" say h/L=12 degrees and h/L =0.35 for example."
The h/L variable is not in degrees but a dimensionless ratio; precisely which dimension isn't provided, but it has to be a height or a distance (length). It may be equivalent to the roof pitch as a ratio rather than the conventional 1 in 12 (inch rise in 12" (1 ft) of run)? Theta is the wind direction in degrees; there are two separate tables here combined; it isn't clear to me without the supporting information on use of the table precisely what the appliction of the two would be to make them consistent. One appears to be for winds normal to the ridge line, but if that were the case it isn't clear what the angle variation would represent?
Anyways, to do interpolation at the ends, the extrapolation value is fixed for the upper end and the definition for theta <10 isn't really clear from the table alone. What the notes (a,b) say may help clarify, otherwise probably will need to see an example of application to fully understand the use in order to write useful code.
Thank you. Yes indeed. I meant to say ' theta=12 degrees and h/L =0.35' which is numbers that are in between the limits. I wanted to know what is the best approach to produce a similar table like this.
I've created row matrices and for those values greated than 80 degree angle for example, I had to put an extra column denoting 90 degrees and putting in values that satisfy this condition. Then, I use interp2 to get values inbetween. However, I wanted to know if there was a better way to do something like this.
That's about all you can do with interp2 since it doesn't allow extrapolation values on upper and lower end; why not is anybody's guess; seems only logical should have.
The alternate is griddedInterpolant although it's one I've not used much, let's try it...
H=[0.25; 0.5; 1.0];
T=[10:5:35 45 60 80]
T = 1×9
10 15 20 25 30 35 45 60 80
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
CP=[-0.18 0.0 0.2 0.3 0.3 0.4 0.4 0.6 0.8;
-0.18 -0.18 0.0 0.2 0.2 0.3 0.4 0.6 0.8;
-0.18 -0.18 -0.18 0.0 0.2 0.2 0.3 0.6 0.8];
Gcp=griddedInterpolant({H,T},CP,'linear','nearest')
Gcp =
griddedInterpolant with properties: GridVectors: {[3x1 double] [10 15 20 25 30 35 45 60 80]} Values: [3x9 double] Method: 'linear' ExtrapolationMethod: 'nearest'
t=[0:25:90]; h=[0:0.5:1.5];
Cp=Gcp({0,0})
Cp = -0.1800
Cp=Gcp({0,90})
Cp = 0.8000
Cp=Gcp({0.25,0})
Cp = -0.1800
Cp=Gcp({0.75/2,40})
Cp = 0.3750
Seems to work although the use of cell arrays for the inputs is somewhat inconvenient
Cp=Gcp({h,t})
Cp = 4×4
-0.1800 0.3000 0.4000 0.8000 -0.1800 0.2000 0.4667 0.7500 -0.1800 0 0.4000 0.7500 -0.1800 0 0.3000 0.8000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Thank you very much. The 'griddedInterpolant' was new to me. I am trying it out. Can Extrapolation work?
You don't want to actually extrapolate; it's used above to bound the ends by using the nearest input points as the extrapolated values...if the inputs are outside the range defined, the closest values will be the endpoints
griddedInterpolant acts differently in that regards; the only options available to interpN is to either actually extrapolate (not wanted here, certainly) or set a constant value which is universal and not a value dependent on which end of the input one is extrapolating from.

Sign in to comment.

Answers (0)

Products

Release

R2023a

Asked:

on 23 Sep 2024

Edited:

dpb
on 25 Sep 2024

Community Treasure Hunt

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

Start Hunting!