How add field to a import structure file *.txt.?
1 次查看(过去 30 天)
显示 更早的评论
Hello fellows I have a problem I need to add a field to a import text file.
I have some field's in a .txt file i need to use , but I need to add a new fields to structure, can someone help me with this?
Thanks in advance
fileID = fopen(fullfile( FilePath, FileName),"r");
%RELOAD FILE DATA IN MATRIX FORMAT WITH ALL COLUMNS
dataAcquisition = readmatrix(fullfile(FilePath,FileName),'NumHeaderLines',headerLine);
%CHOOSE THE COLUMN's WITH THE DATA NEEDED
ixKeep=[1 2:7]
%LOAD ALL REQUIRED FIELDS
dataAcquisition = dataAcquisition(:,ixKeep);
%%%%%%%%%%%%%ADD STRUCTURE WITH A FOLLOWING FIELDS%%%%%%%%%%%%%%
%SAMPLE | TIMESAMPLE | ECG | RESPIRATORY | TEMPERATURE | BATTERY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
validFields = {'sample', 'time_aquisition', 'ecg', 'respiratory', 'temperature', 'baterry'}
2 个评论
Chunru
2022-9-19
You are using readmatrix to get a matrix (rather than a structure). You can add in new culumn to the matrix but not field.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!