How to skip the particular year while writing a code?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Pritha Pande
am 1 Jun. 2017
Beantwortet: Walter Roberson
am 1 Jun. 2017
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 1 Jun. 2017
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Splines finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!