Error in importData text
조회 수: 1 (최근 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!