.csv file converted to 1xN char, not allowing me to use importdata()

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
Stephen23
Stephen23 il 14 Lug 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.
Colin
Colin il 14 Lug 2022
Sorry, the problem is that I get an error when I try to make the data1 variable. When I call importdata(filename1) it gives an error that it is unable to open the file.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 14 Lug 2022
filepath = pwd;
filename1 = fullfile(filepath, 'type1.csv');
data1 = readmatrix(filename1);

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by