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

3 visualizaciones (últimos 30 días)
Colin
Colin el 14 de Jul. de 2022
Comentada: Colin el 14 de Jul. de 2022
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 comentarios
Stephen23
Stephen23 el 14 de Jul. de 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 el 14 de Jul. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 14 de Jul. de 2022
filepath = pwd;
filename1 = fullfile(filepath, 'type1.csv');
data1 = readmatrix(filename1);

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by