Variable file path for importdata

5 ビュー (過去 30 日間)
Matthew Taliaferro
Matthew Taliaferro 2013 年 5 月 9 日
I am unsure why the following code does not work:
str = input('Enter the filename: ', 's');
bottom_temp = fullfile('Temperatures','Bottom',str,'.txt');
BOT_TEMP = importdata(bottom_temp);
But this code does work:
BOT_TEMP = importdata('Temperatures\Bottom\str.txt');
% where str is the name of the file
The first set of code returns: 'Unable to open file'
I have a feeling that there is some simple formatting error that I am overlooking, any help would be appreciated.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 5 月 9 日
bottom_temp = fullfile('Temperatures','Bottom',[str,'.txt'])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by