MATLAB Answers

0

how can I read file from a different directory

Asked by Zeynab Mousavikhamene on 11 Oct 2019
Latest activity Answered by per isakson
on 11 Oct 2019
the matlab script that I am running from is in directory "a" but the I need to read text file using "fileread" from an directory b in the script. How can I navigate from existing directory (running script) which is "a" to directory "b"?

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by per isakson
on 11 Oct 2019
 Accepted Answer

If you know the full directory name of 'b' use that, i.e
chr = fileread( fullfile( 'c:', 'full', 'directory', 'name', 'of', 'b', [ text_file_name, '.txt' ] ) );
This way you can read the file from anywhere

  0 Comments

Sign in to comment.