need helpin solving this.
显示 更早的评论
create a vector X with the elements,
add up the element of the version of this vector that has 100 elements.
thanks for the help.
n= 1:100
Xn= ((-1).^n+1)/(2*n-1)
Xn =
0.0076is this correct?
回答(3 个)
Sg dg
2013-1-2
0 个投票
2 个评论
Image Analyst
2013-1-2
编辑:Image Analyst
2013-1-2
You go first. You can do this in two lines of MATLAB code. What were they and what were your "current answers"? Then we can tell you if you were correct.
Roger Stafford
2013-1-2
As you near the end of your one hundred terms your sum ought to be oscillating roughly equal distances on either side of pi/4. Does that help?
Sg dg
2013-1-2
3 个评论
No. Beware of
* vs .*
and
/ vs ./
Walter Roberson
2013-1-2
The "/" operator is for matrix division. You want ./ which is element-by-element division.
Sg dg
2013-1-2
Image Analyst
2013-1-2
0 个投票
Nope. n is a vector so you need ./ rather than /.
5 个评论
Sg dg
2013-1-2
Sg dg
2013-1-2
Walter Roberson
2013-1-2
You still need to add up the terms.
Sg dg
2013-1-2
doc sum
Example:
a = 1:10;
sum(a)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!