how can I read file from a different directory

2 Ansichten (letzte 30 Tage)
Zeynab Mousavikhamene
Zeynab Mousavikhamene am 11 Okt. 2019
Beantwortet: per isakson am 11 Okt. 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"?

Akzeptierte Antwort

per isakson
per isakson am 11 Okt. 2019
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

Weitere Antworten (0)

Kategorien

Mehr zu File Name Construction finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by