.csv file converted to 1xN char, not allowing me to use importdata()
3 views (last 30 days)
Show older comments
I am very new to matlab and am having trouble using the importdata function. The program gives an error when attempting to import filename1. The workspace defines the filename as being a 1xN char instead of an NxM array -- I think the problem might be there, but I do not know how to go about fixing it. I've attached a snippet of the code and a small .csv file.
Thank you for your help.
% IMPORT DATA
filepath = pwd;
filename1 = strcat(filepath, '\type1.csv');
warning('off', 'MATLAB:table:ModifiedAndSavedVarnames');
data1 = importdata(filename1);
outputfilepath = pwd;
[~foldername] = fileparts(outputfilepath);
exptdesg = 'Folder'
2 Comments
Stephen23
on 14 Jul 2022
"The workspace defines the filename as being a 1xN char ..."
Because that is exactly what a filename is.
"...instead of an NxM array -- I think the problem might be there"
What exactly is the problem? So far it is not clear.
Answers (1)
Walter Roberson
on 14 Jul 2022
filepath = pwd;
filename1 = fullfile(filepath, 'type1.csv');
data1 = readmatrix(filename1);
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!