Error using load Unable to read file No such file or directory.
    조회 수: 66 (최근 30일)
  
       이전 댓글 표시
    
Hi,
I want to run my code but I confront Error using load Unable to read file 'E:\Program Files\MATLAB\R2016a\bin\EegMyDataDir 1\with occular artifact\cnt'  No such file or directory
part of the code is below:
Thanks for help!
clc
clear all
warning off all
close all
%% Parameters
K = 0;
Task_time = 10;
subjects_num = 29;
channel_num = 30;
low_cut_off = 1;
high_cut_off = 45;
filter_order = 4;
%% reading and processing
for subj = setdiff(1:subjects_num,21)    
    load(['E:\Program Files\MATLAB\R2016a\bin\EegMyDataDir ',num2str(subj),'\with occular artifact\cnt'])
    load(['E:\Program Files\MATLAB\R2016a\bin\EegMyDataDir ',num2str(subj),'\with occular artifact\mrk'])
댓글 수: 1
  Jan
      
      
 2019년 6월 25일
				Never, never, never store data or user-defined functions inside Matlab installation folder, e.g. E:\Program Files\MATLAB\R2016a\bin. The effects are not predictable.
답변 (5개)
  Guillaume
      
      
 2019년 6월 25일
        The error message is very clear, there is no file E:\Program Files\MATLAB\R2016a\bin\EegMyDataDir 1\with occular artifact\cnt
If you intended for that file to exist, then you need to find out why it doesn't. It's nothing to do with matlab.
On the other hand, you should never use any directory in Program Files to store your data. That's a sure way of corrupting your software installation. So I'd recommend you use another directory such as My Documents\Matlab to store you files.
Also, since you don't appear to be very experience with matlab, I would strongly recommend not using warning off all. 
댓글 수: 5
  Fabiana
 2023년 10월 16일
				Thanks, @Stephen23. Maybe my doubt should be "how can I informe where are the files that must be read"?
Because I received a script from a colegue:
%%%%%%  Analyse des fichiers Alcool
filename = [C:Users\Donnes\G' cell2mat(GROUPE(groupe)) '_S' num2str(suj) '_' cell2mat(SESSION(session)) '.mat'];
                 datalcool = load(filename);
                 disp(['Traitement Physio en cours du Sujet ' num2str(suj) '(' cell2mat(GROUPE(groupe)) ' ans) en session alcool ' cell2mat(SESSION(session)) ])
                 % Voies des données physiologiques : données brutes
                 EDAraw.valeur = datalcool.mat(:,1);
                 ECGraw.valeur = datalcool.mat(:,2);
                 EEG1raw.valeur = datalcool.mat(:,3);
                 EEG2raw.valeur = datalcool.mat(:,4);
                 datalcool.mat(:,6:9)=[]; 
                 time = (0:1/Fe:(length(datalcool.mat(:,1))-1)/Fe);
                 delt1 = diff(datalcool.mat(:,5));       
                 deltpos1 = find (delt1>0);  
                 deltatime = time(deltpos1(1));
When I supprime the firt part in the braquetes (i.e.C:Users\Donnes\), the error is in variable G'. When I isert ['G' G' cell2mat(GROUPE(groupe)) '_S' num2str(suj) '_' cell2mat(SESSION(session)) '.mat'] the error in "filename"  persist... And I am bloqued in the firt line of the script!
  Stephen23
      
      
 2023년 10월 18일
				@Fabiana: yes, that code is not written to be easily modified nor easily understood. Replace the first two lines with this:
P = 'C:\Users\username\MATLAB'; % define the path here
F = 'nameofyourfile.mat';       % define the name here, use SPRINTF if required
datalcool = load(fullfile(P,F));
  pankhuri kasliwal
      
 2019년 6월 25일
        Check if your file is in the current folder
dir your_file_name.mat
Sometimes the path problem can happen, in that case use this, 
addpath(fullfile('your_path'));
댓글 수: 6
  Fabiana
 2023년 10월 16일
				I can't understand the difference between "added to the matlab path" (because the orientation is Data directories do not need and should not be added to the matlab path.) and "tell it exactly what data files to access" (because the orientation is  instead you should simply and reliably tell it exactly what data files to access. Absolute or relative filenames are accepted by all functions that access data files) 
  Stephen23
      
      
 2023년 10월 28일
				
      편집: Stephen23
      
      
 2023년 10월 29일
  
			@Fabiana: it is very simple:
- the MATLAB Search Path is for code. Putting lots of data folders and data files on the Search Path makes MATLAB slow and debugging your code harder.
- MATLAB functions that import/export data from files accept absolute/relative filenames. Using absolute/relative filenames is efficient and robust. Use FULLFILE if required, e.g.:
P = 'C:\Users\MyName\someFolder'; % absolute or relative filepath
F = 'DataFile.csv';               % filename
T = readtable(fullfile(P,F));
See also:
  Simenew
 2023년 10월 28일
        
      편집: Walter Roberson
      
      
 2025년 2월 25일
  
      clc
clear all
warning off all
close all
% load the absorption spectra
load('absorption_with_plasmon.txt'); % Load the Absorption spectrum with plasmonic effects
load('absorption_without_plasmon.txt'); % Load the Absorption spectrum without plasmonic effects
% Wavelength range
lambda = linspace(350, 700, 50); % Wavelength range in nm
% Interpolate the absorption spectra to match the desired wavelength range
absorption_with_plasmon_interp = interp1(wavelength, absorption_with_plasmon, lambda);
absorption_without_plasmon_interp = interp1(wavelength, absorption_without_plasmon, lambda);
% Calculate the intrinsic absorption enhancement
AE = absorption_with_plasmon_interp ./ absorption_without_plasmon_interp;
% Plot the intrinsic absorption enhancement
figure;
plot(lambda, AE, 'b-', 'LineWidth', 2);
xlabel('Wavelength (nm)');
ylabel('Intrinsic Absorption Enhancement (AE)');
title('Intrinsic Absorption Enhancement in P3HT:PCBM');
grid on;
Abs_enhancement
Error using load
Unable to find file or directory 'absorption_with_plasmon.txt'.
Error in Abs_enhancement (line 2)
load('absorption_with_plasmon.txt'); % Load the Absorption spectrum with plasmonic 
  shailesh kumar
 2025년 2월 11일
        
      편집: Walter Roberson
      
      
 2025년 2월 25일
  
      Error using load
Unable to find file or directory 'garage_fl1_southend.mat'.
Error in untitled3map (line 4)
load garage_fl1_southend.mat scans
>> plese provide file sir
댓글 수: 1
  Walter Roberson
      
      
 2025년 2월 11일
				That file needs Navigation toolbox. I am not currently able to tell what the first version is that had the file; it had appeared by R2021a at latest.
  shailesh kumar
 2025년 2월 25일
        load('offlineSlamData.mat'); please sir provide this file
참고 항목
카테고리
				Help Center 및 File Exchange에서 Search Path에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!








