Unable to open file
8 views (last 30 days)
Show older comments
(Please bare with me this is my first time coding anything at all)
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'.
What am I doing wrong?
Thanks
0 Comments
Answers (1)
Star Strider
on 7 May 2020
4 Comments
Star Strider
on 9 May 2020
My pleasure.
There may be an error in the path string (guessing here because I have no idea how you have organised your computer). Try this:
datatab = readtable('C:/Users/laurenhough/Desktop/CSV/dailytotal.csv')
Otherwise, you should be able to find ‘dailytotal.csv’ easily enough if it’s on your desktop. If it isn¹t there, and if you have Windows (which seems likely), open File Explorer and search for it there. When you find it, move it or copy it to somewhere on your MATLAB search path.
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!