Dot indexing is not supported for variables of this type.

24 次查看(过去 30 天)
I am trying to import a text file (that I have attached) and when I run the code, I get the dot indexing error. I have similar files that I am able to import and I have run a size on each file and the attached file has a size of 1 11 while the other files have size of 4560 11. When using the command line and the uiopen to see the files, they both open inside matlab but when using the following code I get the dot indexing error.
Any advice on why this file returns an error is greatly appreciated.
SLC4PickupMoto1066L=importdata('SLC_Test4_Pickup_Moto_1066L.txt');
SLC4PickupMoto1066L=SLC4PickupMoto1066L.data;

采纳的回答

Walter Roberson
Walter Roberson 2020-3-30
I suspect that the other files do not start with a numeric line before the column headers.
I recommend switching to readtable(). If you are using R2019b or earlier, I would recommend calling detectImportOptions; in R2020a that started being called automatically.
  3 个评论
Aniket Manjare
Aniket Manjare 2020-12-18
i am facing the same issue can you please help me . below is my code
%%
%Data Collection and Labeling
clc;
clear all;
labelPoints = {[2,50],[51,80]};
NoOfFailureModes = 2;
estimateRULFlags = [false, true];
path = 'Datasets/';
labels = {[categorical("OFF"),categorical("ON"),categorical("DUCT BLOCKAGE")],[categorical("OFF"),categorical("ON"),categorical("ROTOR IMBALANCE")]};
rawdata = cell(NoOfFailureModes);
data = cell(NoOfFailureModes);
for i = 1:NoOfFailureModes
rawdata{i} = readtable([path 'Dataset' num2str(i) '.csv'],'Delimiter',','); %Read the downloaded csv file
data{i} = dataParsing(rawdata{i},labelPoints{i},labels{i},i); %Parse the rawdata
end
function data = dataParsing(rawdata,labelPoints,labels,dataset)
bias = 44;
noOfDataPoints = length(rawdata.entry_id);
labelPoints = [0 labelPoints noOfDataPoints];
for i = 1:length(labelPoints)-1
Label(labelPoints(i)+1:labelPoints(i+1),:) = labels(i); %Create Labels for the data points
end
j = 1;
if(dataset == 2)
offset = 0;
else
offset = 2000;
end
for i = 1:noOfDataPoints
text1 = strsplit(rawdata.field1{i},',');
text2 = strsplit(rawdata.field2{i},',');
text3 = strsplit(rawdata.field3{i},',');
text4 = strsplit(rawdata.field4{i},',');
text5 = strsplit(rawdata.field5{i},',');
text6 = strsplit(rawdata.field6{i},',');
var = zeros(length(text1)-1,6);
flag = true;
for k = 1:length(text1)-1 %to neglect the last comma, use -1
var(k,1) = str2num(text1{k})-bias;
var(k,2) = str2num(text2{k})-bias;
var(k,3) = str2num(text3{k})-bias;
if(var(k,1) ~= -bias || var(k,2) ~= -bias || var(k,3) ~= -bias ) %Turning the device off and on will reset the first data set to all zeroes
var(k,4) = str2num(text4{k})-bias;
var(k,5) = str2num(text5{k})-bias;
var(k,6) = str2num(text6{k})-bias;
else
flag = false;
break;
end
end
if(flag) %accept a valid datapoint
data.Label(j,:) = Label(i);
data.sno(j,:) = rawdata.entry_id(i) + offset;
data.X(j,:) = [var(:,1);var(:,4)];
data.Y(j,:) = [var(:,2);var(:,5)];
data.Z(j,:) = [var(:,3);var(:,6)];
j = j+1;
end
end
data = struct2table(data);
end
Walter Roberson
Walter Roberson 2020-12-19
To help debug, in between the call to readtable and the call to dataParsing, please insert
varfun(@class, rawdata{i})
and show us the results for the file that is failing.
Also, please show us the first two lines of the .csv file that it is having the problem with.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by