I am writing a script that takes in user input for creating a table, but I cannot seem to find out how to prompt the user for row and column names based on how many rows and columns they select.
The image shows an example of what kind of table I would like to create.
This is what I have so far:
row = input('Enter number of rows: ');col = input('Enter number of columns: ');for i = 1:row promptRow = ['Row ' num2str(i) ' Name: ']; x = input(promptRow, 's'); for j = 1:col promptCol = ['Column ' num2str(i) ' Name: ']; y = input(promptCol, 's'); str = ['Enter element in row ' num2str(i) ', col ' num2str(j) ': ']; A(i,j) = input(str); endendA;T = array2table(A,... 'VariableNames',{x},... 'RowNames', {y});
Best Answer