Hi friends,
can anyone help me to construct this vectors:
construct a vector containing numbers starting at 20 and counting backwards by ones to 10
construct a vector containing 15 randomly generated numbers between 1and 2

 채택된 답변

Stephen23
Stephen23 2016년 1월 5일
편집: Stephen23 2016년 1월 5일

0 개 추천

Here is the first solution using the colon operator:
>> 20:-1:10
ans =
20 19 18 17 16 15 14 13 12 11 10
Learners learn most when they actually try things and learn from experience. Part of that process is learning where to find information, and actually MATLAB has great documentation which you can easily search using your favorite internet search engine. When I searched for "MATLAB random vector", the first links were the documentation that will tell you how to solve your second task.
If your favorite internet search engine is not working, then follow this link:
Because these tasks are really very basic you should do these tutorials:

댓글 수: 3

Mourchid
Mourchid 2016년 1월 5일
thanks a lot for the first answer, for the seconde one i have a problem to generate the random vector for a specific interval, for example between 1 and 2. How can i do that ?
Guillaume
Guillaume 2016년 1월 5일
편집: Guillaume 2016년 1월 5일
On the first page that Stephen linked, the first entry under Related Examples reads: Random Numbers Within a Specific Range. Does that not answer your question?
In your particular case, since rand returns numbers between 0 and 1, just add 1 to the result to make it between 1 and 2.
Mourchid
Mourchid 2016년 1월 5일
Thank you Guillaume for your answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2016년 1월 5일

편집:

2016년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by