作者bcs (= ="frailty..gggg XD)
看板Statistics
标题[问题] R 画间断函数
时间Fri Apr 13 20:07:54 2007
f(x)= sin(x) if -5<=x<=0
e^x if 1<=x<10
R code:
f<-function(x){
if((x>=-5) && (x<=0)) sin(x)
else if((x>=1) && (x<=100)) exp(x)
}
plot(f,-5,10,type="p")
画出的图却是sin(x) 请问上面哪编错了?
谢谢
--
这因果报应,佛神都逃不了,何况是人!善哉 ╮(﹀_﹀")╭
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.247.214
1F:推 bugle:plot(seq(-5,10,0.1),f(seq(-5,10,0.1)),type='p') 04/13 20:14
2F:推 bugle:上面是plot函数的正确用法,但因为你的f写的有缺陷 04/13 20:17
3F:→ bugle:所以只会画到sin(x) 04/13 20:17