How to collect user input as cell array?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
I am using Matlab Student version 2018b on a windows 10 computer. I am trying to collect my user input as a cell array - like how I am able to store my column headers. The question and the answer are being stored one character per cell, I understand that this is because I am using "()", instead of "{}". However, simply changing the "()" to "{}" does not help. What should I be doing to store the question and answer so that they only occupy one cell each?
col_header={'Question', 'Answer'};
Hello = ('Hello, what is your name?\n');
name = input(Hello, 's')
%FYI, this will create an excel file on your desktop
xlswrite('WriteToDesktop.xls', col_header, 'Sheet1', 'A1')
xlswrite('WriteToDesktop.xls', Hello, 'Sheet1', 'A2')
xlswrite('WriteToDesktop.xls', name, 'Sheet1','B2')
0 comentarios
Respuestas (1)
Walter Roberson
el 22 de Feb. de 2019
col_header={'Question', 'Answer'};
Questions = {'Hello, what is your name?'};
for K = 1 : length(Questions)
Answers{K} = input([Questions{K} '\n'], 's');
end
%FYI, this will create an excel file on your desktop
xlswrite('WriteToDesktop.xls', col_header, 'Sheet1', 'A1')
xlswrite('WriteToDesktop.xls', Questions, 'Sheet1', 'A2')
xlswrite('WriteToDesktop.xls', Answers, 'Sheet1','B2')
You might need to make adjustments to the details of xlswrite.
0 comentarios
Ver también
Categorías
Más información sobre Spreadsheets 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!