Variable file path for importdata

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일

1 개 추천

bottom_temp = fullfile('Temperatures','Bottom',[str,'.txt'])

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by