It's probably that unneeded 'format' option. It works fine without it. Try this, which is more robust than what you have:
baseFileName = 'equity_dataset_30_2.csv';
folder = 'C:/users/Apple/Desktop/MATLAB/Individual Coursework/Q1';
fullFileName = fullfile(folder, baseFileName)
if exist(fullFileName, 'file')
% File exists. Read it into a table.
t = readtable(fullFileName)
else
% File does not exist. Warn the user.
errorMessage = sprintf('Error: file not found:\n\n%s', fullFileName);
uiwait(errordlg(errorMessage));
return;
end
I get the following error while trying to access the nc file. If i get into the folder and try it directly ncread works, but I need to use it in a for loop for a number of similar folders. Any ideas why I get this error?
Error using internal.matlab.imagesci.nc/openToRead (line 1259)
Could not open /sw-test-1-1-141-r28/cpd.nc for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 53)
ncObj = internal.matlab.imagesci.nc(ncFile);
I'm trying to add a feature to my code in which the user can select a country and a numerical limit and matlab will search a data set of locations and dates (dailytotal.csv) for the first value for this country that exceeds the limit and display it.
datatab = readtable('/Users/laurenhough/laurenhough/Desktop/CSV/dailytotal.csv'); %set path to the file location
datareduced = table2array(datatab(:,2:7)); %change from table format
y = {'China', 'UK', 'Spain', 'Italy', 'South Korea', 'USA'};
u = input('Please select a country in quote marks - choices are: China, UK, Spain, Italy, South Korea, USA \n');
v = input('Please define a numerical limit \n') ;
j = strcmp(y,u); %determine which column to use
%throw an error if country typed in wrong
if sum(j) == 0
error('Wrong country typed in')
end
%assume its correctly filled in, find the country column
c = find(j == 1) ;
d = find(datareduced(:,c) >= v);
%display date to screen
datatab(d(1),1)
I'm getting the error 'Unable to open file'.
how can i solve the error of reading permission during loading of number of images from a folder
Direct link to this question
⋮
Direct link to this question
this code is giving error
??? Error using ==> imread at 358 Can't open file "." for reading; you may not have read permission.
help me out to solve this error please
Accepted Answer
Direct link to this answer
⋮
Direct link to this answer
Looks to me as if you're trying to open the directory itself ('./') as if it was an image. The return from dir called on a directory will contain both the directory ('.') and its parent directory ('..'). Either you have to check that what you're trying to open is an image, or list only the images.
HTH
3 Comments
Direct link to this comment
⋮
-
Link
Direct link to this comment
thank u..i extracted only the images.. my code is working now
Direct link to this comment
⋮
-
Link
Direct link to this comment
Hi. I have the same problem but I didn't understand your solution. I am new to matlab.So can you please explain in a little bit more details?
Direct link to this comment
⋮
-
Link
Direct link to this comment
projectdir = 'd:\train2';
d([d.isdir]) = []; %remove all folders including . and ..
all_images = cell(num_files,1);
file_okay = false(num_files,1);
fname = fullfile(projectdir, d(K).name);
all_images{K} = fread(fname);
warning('file "%s" is not a readable image', fname);
all_images = all_images(file_okay);
Sign in to comment.
More Answers (2)
Direct link to this answer
⋮
Direct link to this answer
Try
d=dir('d:\train2\*.bmp');
3 Comments
Direct link to this comment
⋮
-
Link
Direct link to this comment
thank u.. my code is working now..
Direct link to this comment
⋮
-
Link
Direct link to this comment
Hello I have the same issue can you share with me how you solved it ?
tu1=imread('C:\Users\Mostwanted\Desktop\Upgrade 03062016\Upgrade 03062016\Adaptive Exposure\AEx2\','*.jpg');
Direct link to this comment
⋮
-
Link
Direct link to this comment
projectdir = 'C:\Users\Mostwanted\Desktop\Upgrade 03062016\Upgrade 03062016\Adaptive Exposure\AEx2';
d = dir(fullfile(projectdir, '*.jpg'));
all_images = cell(num_files,1);
file_okay = false(num_files,1);
fname = fullfile(projectdir, d(K).name);
all_images{K} = fread(fname);
warning('file "%s" is not a readable image', fname);
all_images = all_images(file_okay);
Sign in to comment.
Direct link to this answer
⋮
Direct link to this answer
1 Comment
Direct link to this comment
⋮
-
Link
Direct link to this comment
Running out of file slots should never result in the error message reported here. The problem here is that the user assumed that the first two names returned were . and .. but Windows with NTFS does not make any promises about the order of files, and in practice there are several valid filename characters that can sort before .
Sign in to comment.
See Also
Categories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.