Unable to open file

8 Ansichten (letzte 30 Tage)
Lauren Hough
Lauren Hough am 7 Mai 2020
Kommentiert: Star Strider am 9 Mai 2020
(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

Antworten (1)

Star Strider
Star Strider am 7 Mai 2020
My guess is that you left out a ‘t’.
Try this:
datatab = readtable('/Users/laurenhough/laurenhough/Desktop/CSV/dailytotal.csv')
Also, I prefer inputdlg or listdlg to input. See if they could make things easier for you.
  4 Kommentare
Lauren Hough
Lauren Hough am 9 Mai 2020
Still no luck, thanks anyway
Star Strider
Star Strider am 9 Mai 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by