필터 지우기
필터 지우기

How to skip the particular year while writing a code?

조회 수: 1 (최근 30일)
Pritha Pande
Pritha Pande 2017년 6월 1일
답변: Walter Roberson 2017년 6월 1일
I have data from 1980 to 2016, and i want to skip year 1992 from this. such that,the trend i am making from the command written below won't include year 1992 and its value.
B=[1980:2016 ],
C = [[0.0641771801575756 ,0.0705314239372543 ,0.169254911748342 ,0.0990499637351591 ,0.0824609982128868 ,0.0727823998431182 ,0.0751631840007672 ,0.0710952435222895 ,0.0716510334748713 ,0.0736190018376645 ,0.0721885991163370 ,0.256978377948127 ,0.129986763409104 ,0.0987830309715417 ,0.0859226479389245 ,0.0796368312126925 ,0.0795688352738768 ,0.120342752230900 ,0.0791018172841989 ,0.0773716181241581 ,0.108283337216576 ,0.108465660032082 ,0.115652007379638 ,0.114943930535510 ,0.128375015353833 ,0.116685880909142 ,0.138821961329473 ,0.133736439249935 ,0.139184962383231 ,0.133372815856175 ,0.133362557160868 ,0.143481889370999 ,0.135834567871762 ,0.133126726127365 ,0.149047349058725 ,0.156772003348878 ,0.148213197724466]],
Bi = linspace(min(B), max(B)),
trend_line = interp1(B, C, Bi, 'spline'),
figure(1)
plot(B,C,'pg', Bi,trend_line,'-r')
grid
  댓글 수: 2
Adam
Adam 2017년 6월 1일
편집: Adam 2017년 6월 1일
You seem to be interpolating onto an arbitrary grid so 1992 is not explicitly included anyway. You should just be able to replace the corresponding C value with a Null though.
Pritha Pande
Pritha Pande 2017년 6월 1일
편집: Walter Roberson 2017년 6월 1일
ok, maybe in the above example i can do it without much efforts But, how to do it in the example presented below?
years = 1980:2016;
for i=1:80
for j=1:80
p = polyfit(years, reshape(seasonal_JJA(i, j, :), 1, []),1);
slopes(i, j) = p(1);
end
end

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2017년 6월 1일
B=[1980:2016 ]
mask = ~ismember(B, 1992);
C = [[0.0641771801575756 ,0.0705314239372543 ,0.169254911748342 ,0.0990499637351591 ,0.0824609982128868 ,0.0727823998431182 ,0.0751631840007672 ,0.0710952435222895 ,0.0716510334748713 ,0.0736190018376645 ,0.0721885991163370 ,0.256978377948127 ,0.129986763409104 ,0.0987830309715417 ,0.0859226479389245 ,0.0796368312126925 ,0.0795688352738768 ,0.120342752230900 ,0.0791018172841989 ,0.0773716181241581 ,0.108283337216576 ,0.108465660032082 ,0.115652007379638 ,0.114943930535510 ,0.128375015353833 ,0.116685880909142 ,0.138821961329473 ,0.133736439249935 ,0.139184962383231 ,0.133372815856175 ,0.133362557160868 ,0.143481889370999 ,0.135834567871762 ,0.133126726127365 ,0.149047349058725 ,0.156772003348878 ,0.148213197724466]],
Bi = linspace(min(B), max(B)),
trend_line = interp1(B(mask), C(mask), Bi, 'spline'),
figure(1)
plot(B(mask),C(mask),'pg', Bi,trend_line,'-r')
grid

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Splines에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by