Enter table with conditional limits and able to interpolate
Show older comments
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.
juan sanchez
on 24 Sep 2024
Edited: juan sanchez
on 24 Sep 2024
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.
H=[0.25; 0.5; 1.0];
T=[10:5:35 45 60 80]
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')
t=[0:25:90]; h=[0:0.5:1.5];
Cp=Gcp({0,0})
Cp=Gcp({0,90})
Cp=Gcp({0.25,0})
Cp=Gcp({0.75/2,40})
Seems to work although the use of cell arrays for the inputs is somewhat inconvenient
Cp=Gcp({h,t})
juan sanchez
on 25 Sep 2024
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.
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!