How i can input values from user in array
Ältere Kommentare anzeigen
Antworten (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
am 22 Sep. 2015
>> x = input('Please enter Matlab matrix> ')
Please enter Matlab matrix> [2 3 4; 5 6 7]
x =
2 3 4
5 6 7
1 Kommentar
Usman Altaf
am 22 Sep. 2015
Chidinma Emmanuel-Okereke
am 27 Feb. 2020
1 Stimme
y = input('Enter numbers in brackets, in the form [x,x,x,x,x,x]:');
1 Kommentar
Saksham C
am 15 Jun. 2021
Remove the commas, give input without it. Eg. [x x x x]
Pankaj Maurya
am 19 Dez. 2021
0 Stimmen
array=input('Inter the array value')
Walter Roberson
am 1 Okt. 2022
0 Stimmen
consider an editable uitable().
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!