How i can input values from user in array
古いコメントを表示
回答 (5 件)
%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
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
Chidinma Emmanuel-Okereke
2020 年 2 月 27 日
1 投票
y = input('Enter numbers in brackets, in the form [x,x,x,x,x,x]:');
1 件のコメント
Saksham C
2021 年 6 月 15 日
Remove the commas, give input without it. Eg. [x x x x]
Pankaj Maurya
2021 年 12 月 19 日
0 投票
array=input('Inter the array value')
Walter Roberson
2022 年 10 月 1 日
0 投票
consider an editable uitable().
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!