Exporting data from strings to excel?
이전 댓글 표시
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
dpb
2014년 4월 20일
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.
답변 (1개)
Image Analyst
2014년 4월 20일
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);
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!