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

3 次查看(过去 30 天)
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 :)

采纳的回答

Image Analyst
Image Analyst 2023-4-12
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 个评论
Amil Ali
Amil Ali 2023-4-12
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 2023-4-13
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);

请先登录,再进行评论。

更多回答(2 个)

Alan Stevens
Alan Stevens 2023-4-12
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 2023-4-12
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

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by