I need to write a program in matlab that searches for specific key words in a text file and then Count the number of this specific word in text.
How can I search a text file for Count specific words using matlab?
555 views Asked by eman At
2
There are 2 answers
0
rinkert
On
Matlab actually has a function strfind which can do this for you. Check the Mathworks doc for more details.
The content of the text file should be stored in a variable:
text = fileread('filename.txt')
Related Questions in MATLAB
- Convert Cell Array of Symbolic Functions to Double Array of Symbolic Functions MATLAB
- How to restrict vpasolve() to only integer solutions (MATLAB)
- "Error in port widths or dimensions" while producting 27
- matlab has encountered an internal problem needs to close
- Minimize the sum of squared errors between the experimental and predicted data in order to estimate two optimum parameters by using matlab
- Solve equation with Crank Nicolson and Newton iterative method in Matlab
- Why options are not available in EEGLAB menu options?
- ash: ./MathWorksProductInstaller: not found, but file exists
- iterative GA optimization algorithm
- Create Symbolic Function from Double Vector MATLAB
- Fixing FEA Model loading with correct units and stress results
- loading variables from a python script in matlab
- Why cannot I set font of `xlabel` in `plotmf` in MATLAB?
- How would I go about filtering non-standardly formatted serial data which contains some junk binary between data entries?
- Cyclic Voltammetry Simmulation in MATLAB, I am running into issues with my data points returning as NaN values, i am a beginner, any help wanted
Related Questions in TEXT-PROCESSING
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Why is my Python script not calling GPT-3.5-turbo API?
- How to properly decode the image from encoded image text from a live ANPR Camera stream?
- Return sentences from list of sentences using user specified keyword
- Determining the type of error and its place in the text
- Implementing Automatic Syllable Splitting and Coloring in a Flutter App
- how to use jq to print one-line per root-level object key?
- how to use jq to print JSON array elements separated by tabs "\t"
- How to print specific values of the etherscan API output with python
- Awk: set RS to include newline and 1st (only) field of next row // logfile "splits" based on custom RS and print matching pattern therein
- How to Create a Comprehensive Character Mapping from Regular to Bold Text in JavaScript, Similar to YayText?
- Split address text into components using Machine Learning
- Designing two programs to accomplish a text-processing task on Windows
- awk find/print paragraph containing multiple patterns
- Extract N lines with no duplicate strings from either of the two first columns
Related Questions in TEXT-PARSING
- For loop is only outputting one nslookup result, when there are multiple
- In a text file, count lines from string 'foo' to first empty line afterwards. Raise exception if 'foo' not found
- Reading a text file with multiple data frames separated by headers in R
- Yacc parser not reducing specific production rules as intended
- Read a csv file with rows of key-values pairs, to be used to create a new csv file with unique keys in the header, and default values in rows
- Python re: I would like to capture multiple lines between a string delimiter
- Convert POM pages from cheezy page-object to site-prism gem
- Translate morse code string which has single spaces between letters and three spaces between words
- grep's output is split by colon when being saved into array
- Awkward to recover line numbers in Python Lark Parser
- Parse a geojson file then output data in a new format
- Powershell - Extract strings before and after specific substring
- Convert years.months formatted string to months in PHP
- Why does Integer.parseInt produce Exception in thread "main" java.lang.NumberFormatException: For input string: ""
- Find a keyword, then display each line until it finds the next keyword in PHP
Related Questions in TEXTSCAN
- Scrape text file with Python and save to new text file as values
- Matlab Scan csv file for data and then read
- MatLab textscan(), from messy format with missing lines
- Error in matlab textread command when trying to retrieve a txt file
- How to read comma-delimited data with some values using commas between quotes
- about reading data in matlab with textscan
- Using Textscan to read a block
- using textscan to read badly formatted CSV file in Octave
- unexpected behavior textscan matlab when skipping characters
- problem when trying to load data with textscan
- Octave - error reading data with textscan function
- How to convert a string to a table with `textscan`?
- Read Large Text File with a While Loop into MATLAB
- read csv file in matlab with rows of different size
- How can i read text file and load data to an array?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
First look at how to read a text file using Matlab, then read the entire data into a cell array using
textscanfunction which is an in-built function in Matlab and compare each element of the array with specific keyword usingstrcmp.I have provided a function that takes filename and keyword as input and outputs the count of keywords present in the file.