2022-06-27
1. cell2mat
Convert the contents of a cell array into a single matrix.
C = {[1] [2 3 4]; [5; 9] [6 7 8; 10 11 12]} M = cell2mat(C);
2. num2cell works for all array types.
a = magic(3) b=num2cell(a)
3. Read Matrix from Text File
1 M= readmatrix('XXXX.text')
4. Read Matrix from Specified Sheet and Range Using Import Options
Preview the data from a spreadsheet file and import numerical data as a matrix from a specified sheet and range.
1 opts = detectImportOptions('airlinesmall_subset.xlsx'); 2 preview('airlinesmall_subset.xlsx',opts) 3 opts.Sheet = '2007'; 4 opts.SelectedVariableNames = [1:5]; 5 opts.DataRange = '2:11'; 6 M = readmatrix('airlinesmall_subset.xlsx',opts)
%% Import10
rows of the first5
variables from the worksheet named'2007'
.
M = readmatrix('airlinesmall_subset.xlsx','Sheet','2007','Range','A2:E11')