matlab如何将符合特定条件的数据导入excel并求出平均值
% outline %step_1 clear %step_2 CurrentWorkingPaht %step_3 a Matrix_r %step_4 Loop getting the 20 close and far values %step_5 writing the Matrix_r into the Excel % clear clc;clear; % currentworkingpath CurrentWorkingPath = fileparts(mfilename( fullpath )); Filename_result = [ result_selectionA_1.txt ]; % set a Matrix_r Matrix_r = zeros(20,2); for i = 1:20 tmpPathname = sprintf( %s\\sub%d\\%s ,CurrentWorkingPath,i,Filename_result); [Col_1 Col_2 Col_3 Col_4 Col_5 Array_type Array_RTs Array_ACC] = textread(tmpPathname, %d%d%d%d%d%d%d%d , delimiter , ); doubleC_Mat = [Array_type Array_RTs]; Matrix_r(i,1) = mean(doubleC_Mat(doubleC_Mat(:,1)12,2)); end % writing into the excel file success = xlswrite( student_update.xls , Matrix_r, sheet1 , B2 ); Series = 1:20; Series = Series ;Conditionnames = {[ student_ID ] [ Close ] [ Far ]}; success = xlswrite( student_update.xls , Series, sheet1 , A2 ); success = xlswrite( student_update.xls , Conditionnames, sheet1 , A1 );