フィルターのクリア

how can i make a single column matrix

3 ビュー (過去 30 日間)
hanish h
hanish h 2015 年 5 月 27 日
編集済み: Walter Roberson 2015 年 5 月 27 日
function [v] = int_col(n)
v = rand([n;-1;1]);
end
in command window
int_col(6)
Error using rand
Size vector should be a row vector with real elements.
Error in int_col (line 2)
v = rand([n;-1;1]);
i have no idea whats wrong in this program
i want to create a column matrix of column n values must be less than n and greater than 1
  1 件のコメント
Stephen23
Stephen23 2015 年 5 月 27 日
編集済み: Stephen23 2015 年 5 月 27 日
  • Do you want floating point values or integer values? It is not clear from the text exactly what output you need: does "values" mean real or integer values?
  • Are the values allowed to repeat, or with no repetitions? Or are you just looking for a random permutation?
  • What random distribution do you need?

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

採用された回答

Stephen23
Stephen23 2015 年 5 月 27 日
編集済み: Stephen23 2015 年 5 月 27 日
Although the original question does not give the basic random number specifications (particularly the number type and if repetitions are allowed or not), perhaps randperm does what you need:
>> randperm(5)'
ans =
1
4
5
3
2

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by