find, change and plot a txt file

1 visualizzazione (ultimi 30 giorni)
Agustin Beruti
Agustin Beruti il 19 Nov 2021
Risposto: Rik il 19 Nov 2021
i have a txt with 8600 words and i have to delete words that are 3 letters or less and words with special characters. then i have to do a plot of those words. how can i do that? i dont know how to start

Risposte (1)

Rik
Rik il 19 Nov 2021
Break it up into tasks you either know how to do, or for which you can google a solution.
So first: how can you read a text file to a Matlab variable? I would suggest using my readfile function, which you can get from the FEX. This will deal with UTF-8 text files properly.
Next step: delete some specific words. Using cellfun is an option, but it will only hide the loop, not remove it. So a loop it is. What do you need to do? For each word you need to find out the number of elements and whether it contains a special character. What do you define as a special character? Is é a special character?
Plotting words is a bit more tricky. What do you mean? Do you want a word cloud? There are probably people who have already posted code on the File Exchange that will do something like that. Or do you want something like a Hamming tree (I don't know if that is the official name)? If you can sketch it, there is probably a way to create it with Matlab.

Prodotti


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by