Error message for extrapolation?

9 ビュー (過去 30 日間)
Shayma Al Ali
Shayma Al Ali 2020 年 12 月 8 日
回答済み: Walter Roberson 2020 年 12 月 8 日
I keep getting an error message when using the interp1 function. For some background, I have 107 files that all have the same variables but different lengths. So I'm trying to extrapolate the variable in each file to have the same lengths.
The error message I keep getting:
Error using interp1>sanitycheckmethod (line 253)
Invalid interpolation method.
Error in interp1>parseinputs (line 376)
method = sanitycheckmethod(varargin{end});
Error in interp1 (line 78)
[method,extrapval,ndataarg,pp] = parseinputs(varargin{:});
Error in PhysOceanFinal (line 54)
zonal1.depths=interp1(zonal1.density,zonal1.depth,[zonal1.depth(end) depths(end),'linear','extrap']);
My code:
direc1=dir('*.mat');
%calculate northward geostrophic velocity using thermal wind relation
%calculate drho/dz by integrating the density
%First interpolate density into uniform depth values
%Use largest depth file as primary depth
load('zonal1_240.mat'); %use this files depth values
depths=zonal1.depth;
%use extrapolate function to get density profile
for i=1:length(direc1)
load(direc1(i).name);
if length(zonal1.depth)<length(depths)
zonal1.depths=interp1(zonal1.depth,zonal1.density,[zonal1.depth(end) depths(end),'linear','extrap']);
end
end

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 12 月 8 日
zonal1.depths=interp1(zonal1.depth,zonal1.density,[zonal1.depth(end) depths(end),'linear','extrap']);
The] is in the wrong place, needs to be before ,'linear'

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by