PDA

查看完整版本 : [讨论]刚接触matlab,有个小问题


qhbupt
2008-04-04, 12:07
我如果想把一个正弦函数离散化的图像画出来应该怎么样呢?

xuf150
2008-04-04, 12:54
偶也是刚学MATLAB的,这个还是比较简单实现吧,直接用plot函数就可以,
MATLAB代码:
x=-pi:0.1:pi;
y=sin(x);
plot(x,y,'+')

这个图像就是用离散的'+'表示,当然也可以用其他的颜色或者符号表示.

b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram