필터 지우기
필터 지우기

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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by