How do code for user input of text file name to be read?

2 visualizaciones (últimos 30 días)
Ari
Ari el 5 de Sept. de 2012
I've been using:
fid=fopen('Doc.txt','r')
so far and have no clue how I'm meant to code for user input of file name which then reads the file.
I'm used to using :
evalresponse = input(promt)
but that's clearly not applicable here.
Also, how do you specify which characters to print to file and which to ignore? Last night I figured out how to create a program to output the number of vowels in a text file.
Now I need to get it to print to file the text document without any vowels and that seems a lot more complicated, at least to a beginner like me.
I've tried the 'type' handle but that just prints to file the entire text indiscriminately. Would really appreciate some help with this.

Respuestas (2)

Oleg Komarov
Oleg Komarov el 5 de Sept. de 2012
Editada: Oleg Komarov el 5 de Sept. de 2012
use uigetfile() to get the name
Use regexprep() to replace vowels and then print the file:
regexprep(str, '[aeiou]','*') % to replace with an asterisk

Image Analyst
Image Analyst el 5 de Sept. de 2012
[baseFileName folder] = uigetfile();
fullFileName = fullfile(folder, baseFileName);

Categorías

Más información sobre Language Support en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by