MATLAB: I didnot understand this code i want help stp_w={‘is’,’the’}; f = fopen(‘gg.txt’); I = textscan(f,’%s’,100);% d=I{1}; for(i=1:2) x = strmatch(d(i), stp_w) If x~=1
MATLAB
this is about classify text document
Best Answer
clc; clear all;
stp_w={'is','the'}; % set of strings is and the
f = fopen('gg.txt'); % gg.txt text file is opened
I = textscan(f,'%s',100); % the data in the file is scanned, it scans into cells
d=I{1}; % the first line data from the text file
for(i=1:2) % loop from 1 to 2
x = strmatch(d(i), stp_w) % trying to find wheter is/the exists in first line using strmatch(stringmatch)
Use fopen,fgetl, fclose to read your file into a cell array and discard the lines you don't want. Or if you want to write a new file, use fopen, fprintf, fclose and write as your read:
fidi = fopen('somefile.txt', 'rt');
fido = fopen('newfile.txt', 'wt');
tline = fgetl(fidi);
while ischar(tline)
if ~isempty(tline) && tline(1) >= '0' && tline(1) <= '9'
Best Answer