how can i ask user to input random numbers and automatically turn it into vector?

조회 수: 2 (최근 30일)
Chrys
Chrys 2020년 4월 25일
댓글: Chrys 2020년 4월 28일
i want to make an input of vectors but i don't know how
for example if you want to input strings you can type:
a = input('please type your name :','s');
but now i want to the user to input random numbers so that i can save it in vector. for example:
the user will input number 1 3 5 7 and then the program will save it into [1 3 5 7]. What should i type to replace ','s'?
please help, thank you.

답변 (1개)

Imanol Isasa
Imanol Isasa 2020년 4월 25일
Hi,
I am not an expert in this but you can try doing just this:
for i=1:4
v(i)=input("Type a random number: ");
end
You can increase i depending on how many numbers you want.
Bye

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by