How can i use th linspace function to to create a vector ‘v’ containing all positive even numbers less than 21. i.e. [2 4 6 8……..]
34 次查看(过去 30 天)
显示 更早的评论
...How can i use th linspace function to to create a vector ‘v’ containing all positive even numbers less than 21. i.e. [2 4 6 8……..]
0 个评论
回答(2 个)
Image Analyst
2013-11-25
Try this:
out = linspace(2, 20, 10)
of course
out = 2 : 2 : 21;
is a lot more straightforward.
2 个评论
Hemz
2019-11-28
编辑:Hemz
2019-11-28
Hi, I am trying to create force my matlab plot to use a step of 10 years and not automatically choose one, so the years start from 2000 to 2100. I want a uniform space 2000, 2010, 2020...2100. How can I do this?
By the way I already tried x = linspace (2000, 2100, 11)
Image Analyst
2019-11-28
That will do it. Another way is to use the colon operator:
>> x = linspace (2000, 2100, 11)
x =
2000 2010 2020 2030 2040 2050 2060 2070 2080 2090 2100
>> x=2000:10:2100
x =
2000 2010 2020 2030 2040 2050 2060 2070 2080 2090 2100
Shane
2013-11-25
A = 0:2:21;
1 个评论
Image Analyst
2013-11-25
0:2:21 does not do what you asked since it includes 0 while you specifically asked that 0 not be included.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!