MATLAB: A=[1 2;n 5;3 5;6 8] ………. very long matrix i want do a condition for reed the rows and when he find a character he delet this rows B=(315151,3) very long matrix expmple reed if you have a character do delet this rows

characterconditiondeletrows

A=[1 2;n 5;3 5;6 8] ………. very long matrix i want do a condition for reed my rows and when he find a character he delet this rows B=(315151,3) very long matrix expmple: reed if you have a character do delet this rows

Best Answer

This reads your sample data file (attached) into a numeric matrix, ignoring the headers and empty lines:
fmt = repmat('%f',1,8);
opt = {'MultipleDelimsAsOne',true, 'CollectOutput',true,'CommentStyle','A'};
[fid,msg] = fopen('AAA.txt');
assert(fid>=3,msg)
C = {};
while ~feof(fid)
C(end+1) = textscan(fid,fmt,opt{:});
S = fgetl(fid);
while isempty(S)
S = fgetl(fid);
end
end
fclose(fid);
M = vertcat(C{:})
And checking the matrix M (the size matches my count of the data rows/columns in your sample data file):
>> size(M)
ans =
213 8
>> M(1:8,:) % first eight rows
ans =
1 1 8780 60511241 5300 5302 92507 3
1 2 8781 60511241 5300 5302 100503 3
1 3 8782 60511241 5300 5302 104701 3
1 4 8783 60511241 5300 5302 110535 3
1 5 8784 60411241 5370 5372 112040 3
1 6 8785 60411241 5370 5372 113813 3
1 7 8786 60411241 5370 5372 122757 3
1 8 8787 61311241 3966 3968 123316 3
>> M(end-7:end,:) % last eight rows
ans =
1 206 8960 61111242 4326 4328 163521 3
1 207 8961 61811247 3075 3077 163546 3
1 208 8962 61111241 4326 4328 163617 3
1 209 8963 61811248 3075 3077 164106 3
1 210 8964 61811249 3086 3088 164439 3
1 211 8965 61811250 3086 3088 164735 3
1 212 8966 61811252 3086 3088 165026 3
1 213 8967 61811252 3086 3088 165135 3
Note that you should add some iteration limit to the while loop, otherwise it could easily go into an infinite loop.