When running a script that includes the 'importdata' function the script fails, however, if I run that same failed 'importdata' line (using Evaluate Selection) straight afterwards, without changing anything in my script or workspace, the 'importdata' function works without problem.
Please can you advice as to what the problem might be and how to solve the problem. I am using Matlab 2014b

댓글 수: 6

Walter Roberson
Walter Roberson 2015년 10월 20일
Please show your code.
dpb
dpb 2015년 10월 20일
And any resulting error(s) in context and in their entirety...
Aimee  Smith
Aimee Smith 2015년 10월 20일
편집: per isakson 2015년 10월 20일
This is part of my code:
path = ['Y:\CCM\CCM Data\' folder 'Data\' skaterfolder];
skaterfile=['sk0' num2str(skater_no) '_'];
%%%Import data %%%%
pedar_filename = ['sk01_c01_2.asc'];
pedar_input=importdata([path pedar_filename]);
When I first execute this code I get the following error:
Error using importdata
Unable to open file
However, if I re-run the line without changing anything
pedar_input=importdata([path pedar_filename]);
The data is read in fine:
pedar_input =
data: [2583x198 double]
textdata: {2591x1 cell}
Is there a problem with the iofun toolbox?
Any help is greatly appreciated!
Don't use path as a variable name. It's the name of a function
>> which path
C:\Program Files\MATLAB\R2013b\toolbox\matlab\general\path.m
Aimee  Smith
Aimee Smith 2015년 10월 20일
I have changed my variable name "path" to another name "folder_data" and I still get the same error.
dpb
dpb 2015년 10월 20일
Yeah, I agree w/ the comment shouldn't alias built-in/TMW-supplied functions but couldn't see that it should have had an effect on the code.

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

답변 (1개)

dpb
dpb 2015년 10월 20일

0 개 추천

Has to be there's something not being shown...like a variable set in the workplace that isn't in the script (which makes me wonder if the "script" is really a function, perhaps?)
As noted before, we need sufficient code in context to see how the error can be reproduced but my guess is on the above. Set a breakpoint within the script/function and I'll bet you can track down the "why" based on local values at that time before the importdata call.

카테고리

도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

태그

질문:

2015년 10월 20일

답변:

dpb
2015년 10월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by