Sum area integration over latitudes

Hi,
I am trying to interpolate vector pr to 0.05 lat grid, a problem arise when I interpolate it to fit from 30 degrees South to 30 degrees North (phi), some values of the interpolation are NAN (Because of negative phi values)!!!! then I am trying to sum the following:
p=sum over 30 degrees south to 30 degree North of (p(i) cos(i)) where i is the latitudes
% close all
clear all
pr=ncread('data.nc','pr');
lat=1:32;
phi=(-30:0.05:30);
prl = interp1(lat,pr,phi,'linear');
%plot(lat,pr,'o')
%hold on
plot(phi,prl,':.');
n=1201;
ptot=0;
for i=n;
p=prl(i)*cos(phi);
ptot=ptot+p;
end

 採用された回答

KSSV
KSSV 2017 年 11 月 13 日
編集済み: KSSV 2017 年 11 月 13 日

0 投票

USe:
prl = interp1(lat,pr,phi,'linear',1);
It does extrapolation also. If still is not working. Attach your .nc file here.

3 件のコメント

Nadine
Nadine 2017 年 11 月 13 日
Doesn't work, here's the pr file, you don't need the entire nc file
KSSV
KSSV 2017 年 11 月 13 日
Try spline instead of interp1
prl = spline(lat,pr,phi);
Remember always extrapolation is not suggested..you are extrapolating values to a large range.
Nadine
Nadine 2017 年 11 月 15 日
it works, but with:
pri=interp1(lat,pr,lati,'spline');
thnx

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2017 年 11 月 13 日

コメント済み:

2017 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by