Matrix interpolation with two vectors as input

I'm trying to interpolate a matrix in MATLAB with two vectors as input. I manage to do this with one value, but not with the whole vector (beta_i and x) as input. The goal is to get out the Goldensteinfactors according to the right beta_i & x values.
%% Correction factors for finite number of blade to determine % values of Ut and Ua at the blades using the Goldstein factors.
% Numbers I want to enter as input in the Goldstein factor matrix x = [0.2030 0.2915 0.3801 0.4687 0.5572 0.6458 0.7343 0.8229 0.9114 1.0000]; beta_i = [0.8182 0.7384 0.6128 0.5158 0.4404 0.3802 0.3304 0.2879 0.2491 0.1862];
% Vertical input in Godstein factor matrix: beta_ii = linspace(0, 70, 15).*pi/180; % Horizontal input in Godstein factor matrix: r_R = [0.95 linspace(0.90, 0.3, 7)];
% Goldstein factors: Xi = [[1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000], [0.804, 0.949, 0.997, 0.999, 1.000, 1.000, 1.000, 1.000], [0.620, 0.810, 0.959, 0.993, 0.998, 0.999, 0.999, 0.997], [0.514, 0.696, 0.890, 0.966, 0.989, 0.994, 0.992, 0.983], [0.440, 0.609, 0.813, 0.921, 0.969, 0.983, 0.982, 0.964], [0.385, 0.539, 0.742, 0.868, 0.938, 0.967, 0.970, 0.946], [0.341, 0.483, 0.679, 0.814, 0.902, 0.948, 0.959, 0.933], [0.307, 0.437, 0.624, 0.763, 0.864, 0.927, 0.950, 0.926], [0.279, 0.400, 0.578, 0.717, 0.828, 0.906, 0.944, 0.927], [0.257, 0.369, 0.539, 0.678, 0.795, 0.886, 0.941, 0.935], [0.240, 0.345, 0.507, 0.644, 0.766, 0.869, 0.941, 0.951], [0.225, 0.325, 0.481, 0.617, 0.741, 0.854, 0.944, 0.973], [0.214, 0.309, 0.460, 0.594, 0.721, 0.843, 0.949, 1.000], [0.205, 0.297, 0.440, 0.576, 0.705, 0.834, 0.956, 1.033], [0.198, 0.288, 0.431, 0.562, 0.694, 0.829, 0.965, 1.068]];
% Interpolation for one value
% vq = interp1(beta_ii, Xi(:,:), 0.7, 'pchip', 1) % vv = interp1(r_R, vq(:,:),0.7, 'pchip',1)
% For the whole matrix beta_i and x
for i = 1:length(beta_i) vq(i) = interp1(beta_ii, Xi(:,i),beta_i(i), 'pchip', 1)
end vq
for j = 1:length(x) vv(j) = interp1(r_R, vq(j,:), x(j), 'pchip', 1) end vv

 Accepted Answer

You have a TWO dimensional array. Not a one dimensional problem, but in two dimensions.
help interp2
use the proper tool for your problem. interp1 is not that tool, while interp2 is.

2 Comments

I tried but it gave an error :
Error using griddedInterpolant Interpolation requires at least two sample points in each dimension.
Error in interp2>makegriddedinterp (line 228) F = griddedInterpolant(varargin{:});
Error in interp2 (line 112) F = makegriddedinterp({X,Y},V,method,extrap);
Error in GoldsteinFactors (line 39) vq = interp2(beta_ii, Xi(:,:),0.7, 'pchip', 1);

Sign in to comment.

More Answers (0)

Categories

Find more on Interpolation 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!