필터 지우기
필터 지우기

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……..]

조회 수: 18 (최근 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……..]

답변 (2개)

Image Analyst
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
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
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
Shane 2013년 11월 25일
A = 0:2:21;

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by