Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- ruby2d
- Vane
- Shell
- Java
- Android
- OTLanguage
- gnuplot
- Python
- boj
- GitHub
- IntelliJ
- 개발노트
- OAuth
- react
- CPP
- JS
- jetbrains
- gradle
- Spring
- error
- RaspberryPi
- plugin
- maven
- rubymine
- 루비
- ruby
- kotlin
- Godot
- Baekjoon
- C
Archives
- Today
- Total
PersesTitan(페르) 기술블로그
[Ruby] 루비로 cos 그래프 구현하기 본문
관련된 글
[Ruby] 루비로 sin 그래프 구현하기
관련된 글 [Ruby] 루비에서 그래프 구현하기 (gnuplot 설치) [Ruby] 루비에서 그래프 구현하기 (gnuplot 설치) 먼저 homebrew가 설치가 되어 있어야합니다. 그리고 아래 커맨드를 터미널에 입력해서 gnuplot를
persestitan.tistory.com
풀이
sin 그래프를 이미 구현하셨다면 해당 코드에서 코드에서 sin을 cos으로 변경만하면 됩니다.
코드
require 'gnuplot'
Gnuplot.open do |g|
Gnuplot::Plot.new(g) do |plot|
x = (-5..5).step(0.1).collect { |v| v.to_f.round 1 }
y = x.collect { |v| Math.cos v }
plot.data << Gnuplot::DataSet.new([x, y]) do |d|
d.with = "lines"
d.linewidth = 2
end
end
end
출력
'Language > Ruby' 카테고리의 다른 글
[Ruby] 루비 팩토리얼 함수 만들기 (0) | 2023.12.01 |
---|---|
[Ruby] 루비로 tan 그래프 구현하기 (0) | 2023.04.12 |
[Ruby] 루비로 sin 그래프 구현하기 (0) | 2023.04.12 |
[Ruby] 루비에서 그래프 구현하기 (gnuplot 설치) (0) | 2023.04.12 |
[Ruby] 루비로 게임 제작해보기 7: 도착 로직 구현 (0) | 2023.01.06 |