I dont understand this error in line 653 and the end goal is to make a graph

2 views (last 30 days)
Hi Guys hopefully some of you guys can help. im pretty new to Matlab 2020a and do not have much experience.
i have entered the following code into my live script : (i have attached and shorten verision of the Sep_Consibio Cloud Datalog.csv in this question)
%% Raw data plot for Septemper
% Data import
tic
opts = delimitedTextImportOptions("NumVariables", 4);
% Specify range and delimiter
opts.DataLines = [1, Inf];
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["Timestamp", "Date", "H2SIn", "H2SOut"];
opts.VariableTypes = ["double", "datetime", "double", "double"];
% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Specify variable properties
opts = setvaropts(opts, "Date", "InputFormat", "dd/MM-yy HH:mm:ss");
% Import online measurement data from Consibio
ConsibioSepdatalog = readtable("Users\amil\Documents\MATLAB\Rawdata2022\Sep_Consibio Cloud Datalog.csv", opts);
ConsibioSepdatalogTrimNew = ConsibioSepdatalog(:,:);
toc
and get the following Error using matlab.io.ImportOptions/readtable (line 653)
Unable to find or open 'Users\amil\Documents\MATLAB\Rawdata2022\Sep_Consibio Cloud Datalog.csv'. Check the path and filename or file permissions. --> however the document is in the same folder as the live script --> i how give my file permission? I'm an apple user and have a MacBook Air (13-inch, 2017) 8 GB 1600 MHz DDR3, icore 5.
the goal is to use the Rawdata in a plot where the x-axis is time [dd.mm.hh.mm:ss] and y- axis is for the concenctration in and out of H2S [ppm]
  • if you have any suggestion for this part of the code please comment :)

Accepted Answer

Image Analyst
Image Analyst on 12 Apr 2023
Since the file is in the same folder as the m-file, you can do
fullFileName = fullfile(pwd, 'Sep_Consibio Cloud Datalog.csv');
if ~isfile(fullFileName)
errorMessage = sprintf('File not found:\n"%s"\nCheck the spelling.')
uiwait(errordlg(errorMessage));
return;
end
% If you get here, the file exists.
fprintf('Processing "%s".', fullFileName)
ConsibioSepdatalog = readtable(fullFileName, opts);
  4 Comments
Amil Ali
Amil Ali on 12 Apr 2023
Ok thx you - No alert was given of the file not exist. That mean with your code i have imported the file i guess.
Image Analyst
Image Analyst on 13 Apr 2023
Yes. So it must have found it. Since it did, it would have printed it out to the command window. If you want a popup message you can do
fullFileName = fullfile(pwd, 'Sep_Consibio Cloud Datalog.csv');
if ~isfile(fullFileName)
errorMessage = sprintf('File not found:\n"%s"\nCheck the spelling.')
uiwait(errordlg(errorMessage));
return;
end
% If you get here, the file exists.
message = sprintf('Success! Found the file!\nNow processing "%s".', fullFileName);
fprintf('%s\n', message); % Print to command window.
uiwait(helpdlg(message)); % Pop up a dialog box with the same info.
ConsibioSepdatalog = readtable(fullFileName, opts);

Sign in to comment.

More Answers (2)

Alan Stevens
Alan Stevens on 12 Apr 2023
Get rid of the gaps between Consibio and Cloud, and between Cloud and Datalog (In the file name and when calling it).

Walter Roberson
Walter Roberson on 12 Apr 2023
ConsibioSepdatalog = readtable("C:\Users\amil\Documents\MATLAB\Rawdata2022\Sep_Consibio Cloud Datalog.csv", opts);
You omitted the drive and leading \ . When you omit the leading \ then you are asking to look in a directory named Users inside your current folder

Categories

Find more on Licensing on Cloud Platforms in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!