Need help with steps and code to complete this.

1 回表示 (過去 30 日間)
Debra Henke
Debra Henke 2019 年 4 月 9 日
編集済み: Jan 2019 年 4 月 9 日
1. Write a short program in matlab that does the following:
(i) Creates a vector that is 100 elements long, containing the numbers 1-20 repeated five times each, occurring in random order within the vector.
(ii) Have the program do this five times, creating five separate vectors, and save them all to a .mat file called "outputVectors.mat" (or similar).
x=(1:100)
I am not sure how to make it repeat in 20s
I tried:
x=(1:20*5)
but it did not work
  3 件のコメント
Debra Henke
Debra Henke 2019 年 4 月 9 日
x=(1:100)
I am not sure how to make it repeat in 20s
I tried: x=(1:20*5)
but it did not work
Jan
Jan 2019 年 4 月 9 日
Whenever you post in the forum, that something does not work, be sure to attach eitehr the complete error message or explain the difference between your expectation and the result. Of course 1:20*5 does work. But you want something else.

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2019 年 4 月 9 日
編集済み: Jan 2019 年 4 月 9 日
Please read the "Getting Started" chapters of the documentation and search in the net for "Matlab onramp" to get a short instruction. The forum is not te best location to learn the basics.
Example:
a = [1,2,3]
b = [a, a]
See also the command
doc repmat
and
doc repelem
Finally you want a random order. Start with reading
doc rand
At the bottom you find a "See also" line, which contains similar commands. One of them helps you to shuffle the elements: You want a random permutation.

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by