I have a 2×219 cell array which looks like this;
06 00 OBDMIDs ExhaustGasSensorMonitorBank1Sensor1 ExhaustGasSensorMonitorBank1Sensor1OBDmonitorIDsSupported$01_$1F supported supported
and so on. 06 00 OBDMIDs is one column. Is there a possibility where i can convert this 2 row array into a 3 row array? For example like this;
06 00 06 00 06 00OBDMIDs ExhaustGasSensorMonitorBank1Sensor1 ExhaustGasSensorMonitorBank1Sensor2 OBDmonitorIDsSupported$01_$1F supported supported
so what i basically want is to keep the 06 00 in first row and move the corresponding values one row down each. this is what i have done till now;
Cstr = textread('Test1.txt', '%s', 'delimiter', ''); cString = Cstr(29:end); %removes headers
cString = char(cString); %Transforms into a char array,...
%split the columns
pdu = cellstr(cString(:, 1)); parameter = cellstr(cString(:, 1:42)); value = cellstr(cString(:, 43:86)); %unit = cellstr(cString(:, 87:end));
ispresent = ~cellfun(@isempty, pdu); %pdu for the rows where it is omitted from
pduvalid = pdu(ispresent);pdu = pduvalid(cumsum(ispresent));newc = [pdu'; parameter'; value']; %desired output
row = 1; newc(row,:) = [];
The original text file and the cell array excel sheet is attached below. I know its just a small problem but somehow i am stuck on it. Thank you for any kind of help in this regard.
Best Answer