MATLAB Answers

0

Error using load Unable to read file No such file or directory.

Asked by Hamid Ebrahmi on 25 Jun 2019
Latest activity Commented on by Hamid Ebrahmi on 25 Jun 2019
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 Comment

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.

Sign in to comment.

2 Answers

Answer by Guillaume
on 25 Jun 2019

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.

  1 Comment

Dear Guillaume,
Thanks for reply,I change the path like the below code but I have the same error
my .mat files are exist at the path
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(['C:\Users\Hamid\EEGBerlin\EEG\eeg data\subject ',num2str(subj),'\with occular artifact\cnt'])
load(['C:\Users\Hamid\EEGBerlin\EEG\eeg data\subject ',num2str(subj),'\with occular artifact\mrk'])

Sign in to comment.


Answer by pankhuri kasliwal on 25 Jun 2019

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'));

  2 Comments

Dear pankhuri,
Thanks for answer but I tried both way that you suggested but again had same error
Data directories do not need and should not be added to the matlab path.

Sign in to comment.