How to plot the same function several times with several different angles
이전 댓글 표시
Suppose I had the equation of y=sin(x), and I wanted to plot the function of this equation several times with angles ranging from [32.1, 46, 81]. How could I input these values into the function in order to graph all these values?
clear all
x1=[32.1, 46, 81]
x= 0:pi:x1
y=sin(x)
plot(x,y)
I thought it'd be this code, but clearly I was wrong. Thanks for any help you guys can provide.
댓글 수: 1
Azzi Abdelmalek
2013년 4월 21일
Avoid using clear all, just use clear
답변 (1개)
Azzi Abdelmalek
2013년 4월 21일
x1=[32.1, 46, 81]
x= 0:0.001:0.2
y=sin(bsxfun(@times,x',x1))
plot(x,y)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!