Error in importData text

1 vue (au cours des 30 derniers jours)
yasmin khattab
yasmin khattab le 17 Août 2015
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 commentaire
xin wang
xin wang le 30 Déc 2022
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? ');
Unable to run the 'fevalJSON' function because it calls the 'input' function, which is not supported for this product offering.
% 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

Connectez-vous pour commenter.

Réponses (1)

Divyam
Divyam le 2 Jan 2025
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

Catégories

En savoir plus sur Standard File Formats dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by