Add header to extrated data from .mat file
%—–create input files for carmaker maneuvers
for i = 1:length(testProcRes.ManoeuvreResults) % Checking the number of data files inside the main mat file.
testinput (:,1)= testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,91); % physical test time in sec
testinput (:,2) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries(:,4); % throttle inputs in percentage
testinput (:,3) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,18); % test steering wheel angle in rad
testinput (:,4) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,19); % Velocity in m/sec
testinput (:,5) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,24); % Brake inputs.
txtname = append(testProcRes.ManoeuvreResults(1,i).ManoeuvreName,’_’,string(i),’.asc’); % Storing the file name
writetable(testinput,txtname,’Delimiter’,’ ‘,’QuoteStrings’,true, ‘Filetype’, ‘text’) % Export data into text file.
In generated txt file i would like to add header for each column eg testinput(:,1) should have time name , so on refer screenshot for more detail%—–create input files for carmaker maneuvers
for i = 1:length(testProcRes.ManoeuvreResults) % Checking the number of data files inside the main mat file.
testinput (:,1)= testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,91); % physical test time in sec
testinput (:,2) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries(:,4); % throttle inputs in percentage
testinput (:,3) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,18); % test steering wheel angle in rad
testinput (:,4) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,19); % Velocity in m/sec
testinput (:,5) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,24); % Brake inputs.
txtname = append(testProcRes.ManoeuvreResults(1,i).ManoeuvreName,’_’,string(i),’.asc’); % Storing the file name
writetable(testinput,txtname,’Delimiter’,’ ‘,’QuoteStrings’,true, ‘Filetype’, ‘text’) % Export data into text file.
In generated txt file i would like to add header for each column eg testinput(:,1) should have time name , so on refer screenshot for more detail %—–create input files for carmaker maneuvers
for i = 1:length(testProcRes.ManoeuvreResults) % Checking the number of data files inside the main mat file.
testinput (:,1)= testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,91); % physical test time in sec
testinput (:,2) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries(:,4); % throttle inputs in percentage
testinput (:,3) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,18); % test steering wheel angle in rad
testinput (:,4) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,19); % Velocity in m/sec
testinput (:,5) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,24); % Brake inputs.
txtname = append(testProcRes.ManoeuvreResults(1,i).ManoeuvreName,’_’,string(i),’.asc’); % Storing the file name
writetable(testinput,txtname,’Delimiter’,’ ‘,’QuoteStrings’,true, ‘Filetype’, ‘text’) % Export data into text file.
In generated txt file i would like to add header for each column eg testinput(:,1) should have time name , so on refer screenshot for more detail add header in text file data MATLAB Answers — New Questions