2

The Universities spread sheat in Excel include:

ID & University Name
0    Mechanical Engineering
1    Civil Engineering

filename = 'test.xlsx';
sheet = 'Universities';
xlRange = 'A2:B31'; 
UniversityNames = xlsread(filename,sheet,xlRange);

but when I display universitynames matrix. I can see ID number but university Name is displayed as 'NaN'. I need to see names of university in this UniversityNames matrix. How can I fix this? OS is Windows 10, Excel 2010.

Engineero
  • 12,340
  • 5
  • 53
  • 75
user768199
  • 25
  • 2
  • 6

1 Answers1

2

Octave's xlsread function has multiple outputs. The first output returned is the numeric data from the input range, which is what you're currently reading in as UniversityNames. The optional second output returns the text strings from the input range, which I'm assuming is what you're looking for. You can also utilize the optional third output, which returns a cell array of the raw strings from the input range.

filename = 'test.xlsx';
sheet = 'Universities';
xlRange = 'A2:B31'; 
[UniversityNames_numeric, UniversityNames_textual] = xlsread(filename, sheet, xlRange);

Or

filename = 'test.xlsx';
sheet = 'Universities';
xlRange = 'A2:B31'; 
[~, ~, rawdata] = xlsread(filename, sheet, xlRange);
sco1
  • 12,154
  • 5
  • 26
  • 48
  • Thanks @excaza . But now when i display UniversityNames_textual i receive UniversityNames_textual = { [1,1] = Mechanical Engineering [2,1] = Civil Engineering } Why does it displays like this ? I only need Names, what are 1,1 and 2,1 and why does it shown with { } – user768199 Dec 08 '17 at 09:57