Dot indexing is not supported for variables of this type
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aniket Manjare
el 18 de Dic. de 2020
Editada: Walter Roberson
el 20 de Dic. de 2020
i am trying to run this code but is not working can you please help me with this
%%
%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
2 comentarios
Adam Danz
el 18 de Dic. de 2020
Provide the full error message, tell us what line is causing that error (the line number is included in the error message but we don't see line numbers so just tell us the line), and describe what variables are used in that line (class & size).
Respuesta aceptada
Walter Roberson
el 19 de Dic. de 2020
for i = 1:noOfDataPoints
var1 = rawdata.field1(i);
var2 = rawdata.field2(i);
var3 = rawdata.field3(i);
var4 = rawdata.field4(i);
var5 = rawdata.field5(i);
var6 = rawdata.field6(i);
%Turning the device off and on will reset the first data set to all zeroes
if var1 ~= 0 || var2 ~= 0 || var3 ~= 0
var = [var1, var2, var3, var4, var5, var6] - bias;
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
2 comentarios
Más respuestas (1)
Cris LaPierre
el 18 de Dic. de 2020
The error appears to be line 36
text1 = strsplit(rawdata.field1{i},',');
The current error is because the variable field1 contains numeric info. Brace indexing - {i} - is not valid for a vector of doubles. Use parentheses instead.
This will lead to your next error. The function strsplit is for text data. You will get another error:
First input must be either a character vector or a string scalar.
4 comentarios
Comunidades de usuarios
Más respuestas en ThingSpeak Community
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!