From: Pr B on 29 Mar 2010 16:42 i have the following text in a .txt file: In what distant deeps or skies Burnt the fire of thine eyes? On what wings dare he aspire? What the hand dare seize the fire? how do i count the number of occurrences of the word 'what' in the file? also, how do i split the poem into multiple strings in a cell array, using the question marks as separators?
From: the cyclist on 29 Mar 2010 16:52 "Pr B" <pb2297(a)columbia.edu> wrote in message <hor3at$5b7$1(a)fred.mathworks.com>... > i have the following text in a .txt file: > > In what distant deeps or skies > Burnt the fire of thine eyes? > On what wings dare he aspire? > What the hand dare seize the fire? > > how do i count the number of occurrences of the word 'what' in the file? also, how do i split the poem into multiple strings in a cell array, using the question marks as separators? Could this question be accurately rephrased as "How do I do my homework?" If so, maybe you could show post some of the code that you have already written trying to solve this, and we could give you some pointers?
From: Pr B on 29 Mar 2010 17:11 actually, no. i'm using it as an example for a much larger string / cell array project i'm working on. feel free to comment on my approach below, though: for counting the number of occurrences of 'what' (case insensitive), i'm using strfind strfind(S, 'what') where S is the input text. however, S isn't a string but is instead a cell, which is why i'm having difficulty counting the number of occurrences. do i need to import the data as an array, use cellstr, and then count the number of occurrences using strfind? as for the storing in individual cells, well, i'm clueless. "the cyclist" <thecyclist(a)gmail.com> wrote in message <hor3to$e63$1(a)fred.mathworks.com>... > "Pr B" <pb2297(a)columbia.edu> wrote in message <hor3at$5b7$1(a)fred.mathworks.com>... > > i have the following text in a .txt file: > > > > In what distant deeps or skies > > Burnt the fire of thine eyes? > > On what wings dare he aspire? > > What the hand dare seize the fire? > > > > how do i count the number of occurrences of the word 'what' in the file? also, how do i split the poem into multiple strings in a cell array, using the question marks as separators? > > Could this question be accurately rephrased as "How do I do my homework?" If so, maybe you could show post some of the code that you have already written trying to solve this, and we could give you some pointers?
|
Pages: 1 Prev: Using a for loop with ode45, 2nd order ODE Next: Kaiser-Meyer-Olkin Index of Sampling Adequacy |