2014-09-24 68 views
0

我在Matlab中新,我試圖繪製在Matlab這一功能:系列繪製在Matlab

enter image description here 我使用下面的代碼:

t = -2*pi:0.01:2*pi; 
f = sum(cos(2*pi*i*t), i = 1 .. 10); 
plot(t, f) 

但我得到這個消息的錯誤:

f = sum(cos(2*pi*i*t), i = 1 .. 10); 
          | 
Error: The expression to the left of the equals sign is not a valid target for an assignment. 

任何人都可以幫助我嗎?

EDIT: I am using Matlab 2013a 
+2

@lakesh因爲't'是1x1257和'1:10'是1×10,'1:10 * t'不管用。 @marcelo'f = sum(cos(2 * pi * i * t),i = 1..10);'不是Matlab語法。閱讀'sum'文檔:http://www.mathworks.com.au/help/matlab/ref/sum.html。 – David 2014-09-24 04:29:13

回答

2
t = -2 * pi : 4 * pi/500 : 2 * pi; 
f = sum(cos(2 * pi * (1 : 10)' * t), 1); 
plot(t, f); 
  • DOC總和,當然))