Editing the cell array
Show older comments
my cell array looks like this; %original file is also attached below.
'1.1 ECU Identification (Ford Escape Initial)'
'============================================'
'PDU Parameter Value Unit'
'----------------------------------------------------------------------------------------------------'
'06 00 OBDMIDs OBDmonitorIDsSupported$01_$1F '
' ExhaustGasSensorMonitorBank1Sensor1 supported '
' ExhaustGasSensorMonitorBank1Sensor2 supported '
'06 01 Monitor ID ExhaustGasSensorMonitorBank1Sensor1 '
' testValue 0.009 s'
' minimumTestLimit 0.000 s'
' maximumTestLimit 0.400 s'
' Test ID 0x87 '
' Monitor ID ExhaustGasSensorMonitorBank1Sensor1 '
' testValue 0.020 s'
' minimumTestLimit 0.000 s'
' maximumTestLimit 0.400 s'
' Test ID 0x88 '
'06 02 Monitor ID ExhaustGasSensorMonitorBank1Sensor2 '
' testValue -7876 mV/s'
' minimumTestLimit -30000 mV/s'
' maximumTestLimit 0 mV/s'
' Test ID 0x85 '
' Monitor ID ExhaustGasSensorMonitorBank1Sensor2 '
' testValue 1.889 s'
' minimumTestLimit 0.000 s'
' maximumTestLimit 6.000 s'
' Test ID 0x86 '
'06 20 OBDMIDs OBDmonitorIDsSupported$21_$3F '
' CatalystMonitorBank1 supported '
' VVTMonitorBank1 supported '
' EVAPmonitorCapOff not supported '
' EVAPmonitor_0_090 supported '
' EVAPmonitor_0_040 supported '
' EVAPmonitor_0_020 supported '
' PurgeFlowMonitor supported '
'06 21 Monitor ID CatalystMonitorBank1 '
' testValue 0.062499 ratio'
' minimumTestLimit 0.000000 ratio'
' maximumTestLimit 0.761709 ratio'
' Test ID 0x81 '
'06 3A Monitor ID EVAPmonitor_0_090 '
' testValue -23.25 Pa'
' minimumTestLimit -996.25 Pa'
' maximumTestLimit 8191.75 Pa'
' Test ID 0x80 '
' Monitor ID EVAPmonitor_0_090 '
' testValue -1992.50 Pa'
' minimumTestLimit -8192.00 Pa'
' maximumTestLimit -1992.50 Pa'
' Test ID 0x82 '
'06 3B Monitor ID EVAPmonitor_0_040 '
What i need to do is to rearrange it in such a way;
File 06 01 06 01 06 01 06 01 06 01 06 02..
Monitor ID testValue minTestLimit maxTestLimit Test ID ...
Test1 ExhaustGasSensorMonitorBank1Sensor1 0.009 0.000 0.400 0x87 ...
and so on. i think i need to loop through all the cell array to get the desired formation but i dont know how to do it. This is what i have done till now.
pwd %identify current Folder
path=fullfile(pwd,'*.txt'); %looks for text files
dir(path) %displays the text file
path=uigetdir(); %open folder selection dialog box
A=genpath(path); %generates path string, returns all folders and subfolders
B=strread(A,'%s','delimiter',';'); %creates cell Array
for p=1:numel(B) %lists all the text files
file=dir(fullfile(B{p},'*.txt'));
end
Cstr = textread('Test1.txt', '%s', 'delimiter', ''); %read file into cell array of strings
Any help in this regard is greatly appreciated. Thank you.
3 Comments
yousaf obaid
on 15 Jun 2016
@yousaf obaid: presumably that data is being read from some data file. It might be easier if you edit your question and upload the file so that we can run our own code on it. This makes helping you much easier.
Probably you do not want the output to be a cell array, but some new file. Please explain a bit more what you are actually trying to achieve, because there may be easier ways to achieve it than simply "rearranging" a cell array.
yousaf obaid
on 15 Jun 2016
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!