How i can input values from user in array

조회 수: 25 (최근 30일)
Usman Altaf
Usman Altaf 2015년 9월 22일
답변: Walter Roberson 2022년 10월 1일
a=input('Enter no ')

답변 (5개)

Kai
Kai 2022년 9월 30일
편집: Kai 2022년 9월 30일
%I havent seen a good answer for this question, so I figured I'd give it a
%shot, this is what I came up with, Kai
%Goal, input user values into an array, Works exact same for matrix just
%that only put in 1 row or 1 columnn and you have an array
%because of broadness of question, lets make a matrix of our own
sizeRow = input('How many rows of a matrix do you want: ');
sizeColumnn = input('How many columns of a matrix do you want: ');
matrix = [];
%for each row, for each column, lets add the user value to __ matrix
for i = 1:sizeColumnn
for j = 1:sizeRow
matrix(j,i) = input(['Enter values for columnn ' num2str(i) ' : ']);
end
end
%Lets see what our matrix is now
matrix

Thorsten
Thorsten 2015년 9월 22일
>> x = input('Please enter Matlab matrix> ')
Please enter Matlab matrix> [2 3 4; 5 6 7]
x =
2 3 4
5 6 7
  댓글 수: 1
Usman Altaf
Usman Altaf 2015년 9월 22일
I mean user does not know how to write matrix. program should be able to take values in matrix

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


Chidinma Emmanuel-Okereke
Chidinma Emmanuel-Okereke 2020년 2월 27일
y = input('Enter numbers in brackets, in the form [x,x,x,x,x,x]:');
  댓글 수: 1
Saksham C
Saksham C 2021년 6월 15일
Remove the commas, give input without it. Eg. [x x x x]

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


Pankaj Maurya
Pankaj Maurya 2021년 12월 19일
array=input('Inter the array value')

Walter Roberson
Walter Roberson 2022년 10월 1일
consider an editable uitable().

카테고리

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