利用Piecewise所建立的函數在x軸未定義的地方會顯示零值
f[x_]:=Piecewise[{{x^2,x > 1},{x,0< x <1},{-x,-1< x <0}}] Plot[f[x],{x,-2,2},PlotStyle->Thickness[0.02]] (*將y=0的點剔除*) Plot[f[x],{x,-2,2},PlotStyle->Thickness[0.02]]/.Line[pt___]:>Line[Select[pt,#[[2]]!=0&]]
f[x_]:=Piecewise[{{x^2,x > 1},{x,0< x <1},{-x,-1< x <0}}] Plot[f[x],{x,-2,2},PlotStyle->Thickness[0.02]] (*將y=0的點剔除*) Plot[f[x],{x,-2,2},PlotStyle->Thickness[0.02]]/.Line[pt___]:>Line[Select[pt,#[[2]]!=0&]]
Copyright 2009 Engadget's Style - Design by FUNction, Ray Wei - Powered by Blogger
讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~