Borrar filtros
Borrar filtros

Exporting data from strings to excel?

1 visualización (últimos 30 días)
Mahmoud
Mahmoud el 20 de Abr. de 2014
Respondida: Image Analyst el 20 de Abr. de 2014
Hello, I have an excel file containing: Names, ID numbers and Grades of 201 students for a midterm, I managed to read the file in Matlab and now I'm required to export the grades of the students with their surname and also their e-mails (e-mail is the same as the ID in the excel file I read but with e in the beginning and without the last number of course adding @) for example the ID: 1234567 will become e123456@abcd.com. And then export all the grades below 60 combined with their e-mail and name to a new sheet. Any help will be appreciated, I think we need to write a loop but I can't figure out how. Thanks in advance
  1 comentario
dpb
dpb el 20 de Abr. de 2014
Rules w/ homework (or HW-like) questions are the poster needs to show what they've done so far to attack the problem and ask specific questions on Matlab syntax or issues where stuck. We don't just do solutions...doesn't help either.
Some hints here--
doc xlswrite % shows how to write mixed cell data to Excel
Generating the strings shouldn't be a real challenge if you store them correctly on reading--don't/shouldn't need a loop to build the array.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 20 de Abr. de 2014
Just use a table and readtable() and writetable(). For example make simple modifications to this, which I slightly modified from the help documentation.:
% Create a table
% T = readtable(excelWorkbookFileName);
T = table(['M';'M';'F';'F';'F'],[38;43;38;40;49],...
[71;69;64;67;64],{'abc'; 'def'; 'fgh'; 'jkl'; 'zzz'})
% Modify variable names
T.Properties.VariableNames = {'Gender' 'Age' 'Height' 'email'}
for k = 1 : size(T, 1)
newEmail = strcat(T.email(k,:), '@university.edu');
T.email(k) = newEmail;
end
% Print to command window
T
% Write to new workbook
% writetable(T, outputWorkbookFilename);

Community Treasure Hunt

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

Start Hunting!

Translated by