Importdata Command not accepting input argument

Hello, Well I know this should be a pretty simple task, but I have been unable to use the importdata command. what I have is this
>> FILENAMES{j}
ans =
'L1S11_0_0.mat'
>> importdata(FILENAMES{j})
??? Error using ==> importdata at 136
Unable to open file.
The file is there because when I use the command in this way
>> importdata('L1S11_0_0.mat')
ans =
cycles: 0
load: 0
comment: 'Baseline'
condition: 'Baseline'
path_data: [1x252 struct]
straingage_data: [1x1 struct]
XRay_data: [1x1 struct]
It works perfectly.
I have +100 files to import and I cant simply write the names manually each time with every importdata command.
Can you say what could I be doing wrong?
By the way: I am using Matlab R2010a
Thanks

댓글 수: 1

Margarita
Margarita 2014년 6월 4일
편집: Margarita 2014년 6월 4일
when I run the line
strcmp(FILENAMES{j}, 'L1S11_0_0.mat')
It returns a "0". They should be the same so why is matlab taking them as different? (The difference is in the presence or lack of the '' sign)

댓글을 달려면 로그인하십시오.

답변 (1개)

Niklas Nylén
Niklas Nylén 2014년 6월 3일
Filenames seems to be a cell of cells, you can tell from ans being 'L1S11_0_0.mat' rather than just L1S11_0_0.mat. This should work:
importdata(FILENAMES{j}{1})

댓글 수: 7

Yes indeed FILENAMES is a cell but using your suggestion still yields no result...
>> class(FILENAMES)
ans =
cell
>> importdata(FILENAMES{j}{i})
??? Cell contents reference from a non-cell array object.
{1}, not {i}.
sorry it was a typo, I did write {1} instead of {i}.
I have also tried to create a temp variable such as namefile='L1S11_0_0.mat' an use the command as importdata(namefile) but it is still showing the same error
Using your example works well for me. Are you sure that the mat file is in your Matlab path?
yes I am sure, I verified it with the "dir" and it is there. I am starting to think that I have some kind of different setting in my computer, but I can't find what it is. From logic what is written in the example should be working.
Margarita
Margarita 2014년 6월 4일
편집: Margarita 2014년 6월 4일
Any ideas of how could I refer this problem? Matlab is not taking the variables to have the same value (FILENAMES and 'L1SS1_0_0')
what happens if you run
exist(FILENAMES{j}{1},'file')

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

질문:

2014년 6월 3일

댓글:

2014년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by