How i can input values from user in array

16 visualizaciones (últimos 30 días)
Usman Altaf
Usman Altaf el 22 de Sept. de 2015
Respondida: Walter Roberson el 1 de Oct. de 2022
a=input('Enter no ')

Respuestas (5)

Kai
Kai el 30 de Sept. de 2022
Editada: Kai el 30 de Sept. de 2022
%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 el 22 de Sept. de 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 comentario
Usman Altaf
Usman Altaf el 22 de Sept. de 2015
I mean user does not know how to write matrix. program should be able to take values in matrix

Iniciar sesión para comentar.


Chidinma Emmanuel-Okereke
Chidinma Emmanuel-Okereke el 27 de Feb. de 2020
y = input('Enter numbers in brackets, in the form [x,x,x,x,x,x]:');
  1 comentario
Saksham C
Saksham C el 15 de Jun. de 2021
Remove the commas, give input without it. Eg. [x x x x]

Iniciar sesión para comentar.


Pankaj Maurya
Pankaj Maurya el 19 de Dic. de 2021
array=input('Inter the array value')

Walter Roberson
Walter Roberson el 1 de Oct. de 2022
consider an editable uitable().

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by