clear %% xlsread [NumVar,txtVar,raw]=xlsread('crabs') FullColumnNames=txtVar(1,1:7) % all nominal initial data NamesProperties=FullColumnNames NamesProperties(2:3)=[] % delete names of column of {'color' 'spine condition'} % xlswrite - if you want, you can find in ML Help %% readtable - suitable for the following formats: %% .txt, .dat; .csv - Excel format (delimited text too) %% .xls, .xlsb, .xlsm, .xlsx,... or .ods tcrab=readtable('crabs.xlsx'); %writetable - see ML Help %% The choice the part of the table NumDataCrabs=tcrab(:,[1,4:7]) % 'Y' 'width' 'sattelts' 'weight' 'catwidth' data_width= table2array(NumDataCrabs(:,2)) % the width has been selected md=median(data_width) sortedWidth=sort(data_width); M=length(data_width) if mod(M,2)==0 OrdinaryMedianWidth=(sortedWidth(M/2)+sortedWidth(M/2+1))/2 else OrdinaryMedianWidth=sortedWidth(round(M/2)) end % middle element for an odd-sized sample or the average of the two central elements for an even-sized sample summary(NumDataCrabs) % ~summary(NumDataCrabs,1) along rows %% look at the result truefalse=istable(tcrab(1,3)) %Nominal Variables were represanted as tcrab(1,3) % Char elements of MATLAB, but they do not % exist as separate elements, but only as part % of the table, even for a single element %% Convert to array (numeric) MatrixCrabs=table2array(NumDataCrabs) % Statistical Analysis based on Matrix, f.e.: corrcoef(MatrixCrabs) %% save NameMatFile var1 var2 - as NameMatFile.mat save DataForAnalysis NamesProperties MatrixCrabs % NameMatFile ~ DataForAnalysis.mat % var1 ~ NamesProperties; var2 ~ MatrixCrabs %% check inverse operation: PartTableCrabs=array2table(MatrixCrabs,'VariableNames',NamesProperties) %_________________________Correctly__________________________________% %% DataForAnalysis.mat this file should be located in the folder with the main program! clear load DataForAnalysis % see Workspace