'Unable to open file' error with importdata
20 次查看(过去 30 天)
显示 更早的评论
I am trying to import data from a .txt file with the same structure as below
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/344913/image.jpeg)
with the code below, I am looking for a .txt file and I try to save each column in a matlab file but matlab tells me 'Unable to open file'
[filename,pathname]=uigetfile({'*.fl.txt' 'Torque file (*.fl.txt)'},'Select a torque curve');
if filename ~= 0
Spill = importdata(filename);
extracted=Spill.data
CDC_N=extracted(:,1)
CDC_Torque=extracted(:,2)
save('CDC.mat','CDC_N','CDC_Torque');
end
if anyone could help me, I'd be grateful.
thanks
0 个评论
采纳的回答
per isakson
2020-8-12
编辑:per isakson
2020-8-12
Replacing
Spill = importdata(filename);
with
Spill = importdata( fullfile( pathname, filename );
may help.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!