Finding average length of elements in a cell array
2 views (last 30 days)
Show older comments
In my code I am sorting through a collection of tweets. I have separated out the handles (ex: @Handle) by using the following code.
FID = fopen('Tweets.txt');
Line = fgetl(FID);
while ischar(Line)
%Finds total amount of handles in the tweets%
Handles={};
FileContents = fileread('Tweets.txt');
Handles = length(regexp(FileContents, '@'));
for h = 1;size(Handles);
HandlesString = num2str(Handles);
RegHandles = regexp(HandlesString, '(#)\w+','match');
end
if regexp(Line, '@')>1;
%I
%Displays all Handles in a CELL ARRAY%
HandlesNum = HandlesNum+1;
RegHandles2 = regexp(Line, '(@)\w*', 'match');
CharHandles = char(RegHandles2);
NumHandles = str2num(Char);
HandlesCell = cell(RegHandles2);
disp(HandlesCell)
end
Numbers = [Numbers; Num];
Line = fgetl(FID);
end
What I am now attempting to do is to find the average (mean) length of all the handles in the file. How could I go about this process?
0 Comments
Answers (0)
See Also
Categories
Find more on String Parsing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!