Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Brace indexing is not supported for variables of this type.

1 vue (au cours des 30 derniers jours)
Aniket Manjare
Aniket Manjare le 18 Déc 2020
Clôturé : Cris LaPierre le 18 Déc 2020
I have a csv file. in the function, this file should be read and then processed.
But i get error 'Dot indexing is not supported for variables of this type.'
How can i solve this? I attached my csv file.
Thnaks
%%
%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

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by