0
votes

I have

myFile = fullfile(x,'myFile.txt');

I would like to redirect stdout to print the content of myFile in console

is there a known function doing that ? Thanks

2
Do you want to print the content of the variable, or of the text file? In the first case remove the semicolon at the end. Otherwise just read the file and print its contents/ - Dennis Jaheruddin

2 Answers

1
votes

One easy way to read text file is using urlread

myfile=['file:///' fullfile(x,'myFile.txt')];
str = urlread(myfile) 

as simple as that

0
votes

Try this:

myFile = fullfile(x,'myFile.txt');
textread (myfile)

textread function provide different options about the format of the file. you can find more details in help of textread.