Error in importData text
2 次查看(过去 30 天)
显示 更早的评论
The problem in importing my data, my M file where i loop on files and calculate mean, i get an error message saying
Error in Untitled2 at 10
mydata{k} = importdata(myfilename, ' ' );
Caused by:
Error using text scan
Unable to read any data from the file, text scan may not have read access.
and i checked and found mydata{k} is empty...i have no idea and i really need help to run this m file ?
the code is followed
close all
clear all
clc
numfiles = 10;
mydata = cell(1, numfiles);
values=[];
for k = 1:numfiles
myfilename = sprintf('tt%d.txt',k);
mydata{k} = importdata(myfilename, ' ' );
values{k} = mydata{k}(:,2);
m= mean(values{k});
fid=fopen('MeanOutputTT.txt','at');
fprintf(fid, '%f', m');
fprintf(fid, '\n');
fclose(fid);
end
1 个评论
xin wang
2022-12-30
Nice to meet you, I'd like to ask whether you have solved your question. I've a similiar code like yours. And I want to know how to solve this question like error in import data, thank you very much!
clc
clear all
close all
% Assignments
zdimension = input('Number of .tif images? ');
% Subvolume is the region in which 3D data will be cut around three-phase
% contact point
subvolume = input('Dimension of subvolume? ');
subvolume = subvolume/2;
mydata = cell(1, zdimension);
% Import .tif images in MATLAB
% !!If different number of figures, change %03d!!
for k = 1:zdimension
myfilename = sprintf('CPline%03d.tif', k);
mydata{k} = importdata(myfilename);
end
回答(1 个)
Divyam
2025-1-2
It appears that MATLAB does not have the read permissions for the file. Since the file exists on MATLAB path it can happen that some other program is performing some operations on the file or the file is open for read in a different location. To avoid this, close all instances of the programs that may read/perform operations the file.
If this does not resolve the error then you could try to use the "readtable" function for the purpose of reading the file data.
For more information regarding the "readtable" function, refer to this documentation: https://www.mathworks.com/help/matlab/ref/readtable.html
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Standard File Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!