raw=WolframAlpha[
"albert einstein",{{"PopularityPod:WikipediaStatsData",1},
"TimeSeriesData"}];
data=Map[{#[[1,{1,2,3}]],#[[2,1]]}&,raw];
DateListPlot[data,Joined->True,AspectRatio->0.25,
ImageSize->750]
hpeaks[data_]:=Select[Split[data,#1[[2]]<=#2[[2]]&],
Length[#]>1&][[All,-1]];
lpeaks[data_]:=
Select[Split[data,#1[[2]]>#2[[2]]&],Length[#]>1&][[All,-1]];
DateListPlot[{
data,
{#[[1]],1.25#[[2]]}&/@hpeaks[data],
{#[[1]],0.75#[[2]]}&/@lpeaks[data]},
Joined->True,
InterpolationOrder->{1,2,2},
Filling->{2->{3}},
FillingStyle->{Hue[1/3,1/3,1/3],Opacity[0.1]},
AspectRatio->0.25,
ImageSize->750,
Epilog->{Red,Point@hpeaks[data],Green,Point@lpeaks[data]}]
Mathematica 教學:Peak detection
由 戴忠淵 於 2013年8月16日星期五
下午3:01 發表

讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~