Azzera filtri
Azzera filtri

Unable to open file

12 visualizzazioni (ultimi 30 giorni)
Lauren Hough
Lauren Hough il 7 Mag 2020
Commentato: Star Strider il 9 Mag 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

Risposte (1)

Star Strider
Star Strider il 7 Mag 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 Commenti
Lauren Hough
Lauren Hough il 9 Mag 2020
Still no luck, thanks anyway
Star Strider
Star Strider il 9 Mag 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.

Accedi per commentare.

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by