Unable to open file
8 次查看(过去 30 天)
显示 更早的评论
(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 个评论
回答(1 个)
Star Strider
2020-5-7
4 个评论
Star Strider
2020-5-9
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!