User's input as Table-Row
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a specific question:
There is a program,which asks from the user to enter a number as an answer into a question. Later, I want this answer(a number from 3 to 10),
to be the number of rows in a table. Although I can fix simple rows,columns and name them, I cannot find a way, to develop a code
which will select the number-input of the user, as number of the rows(for example if he picks 5, I want the program to create a 5-row array)
I cannot make a pre-ordered array because I don't know what the user is going to select.
How I can ask from MATLAB to give me,as many rows, as the number that will be picked
by the user?
0 comentarios
Respuestas (1)
Florian Floh
el 5 de Abr. de 2020
Here is my suggestion on how to approach this problem:
% Here is your user input
userInput = 3;
% create an array containing zeros (or uses ones if it should contain 1s)
% that has one column
yourArray = zeros(userInput,1);
% Convert your array to a table
T = array2table(yourArray);
% Rename the column, if desired
T.Properties.VariableNames = {'NameOfColumn'};
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!