Dot indexing is not supported for variables of this type

11 visualizaciones (últimos 30 días)
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
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).
Aniket Manjare
Aniket Manjare el 18 de Dic. de 2020
Here i have scrrenshot of error and i have also attaches the data set

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
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
Aniket Manjare
Aniket Manjare el 19 de Dic. de 2020
Thanks, i have labelled my data with code, Thakyou
Aniket Manjare
Aniket Manjare el 19 de Dic. de 2020
I am facing the issue with the further part of the code. Please help me to solve this
The error is occuring here ar this point
P1 = P2(1:L/2+1)
Please find the attachment for program file .m and datasets files, Kindly help
below is the code for the exploration:
%%
%Data Exploration
fs = 100; %Sampling Frequency
L = 100; %Length of each data sample is 100 sensor readings
f = fs*(0:(L/2))/L; % Frequency bins until Nyquist Frequency at which FFT is computed
convertToMinutes = (1/fs)/60; %Convert sample number to minutes 0.01/60
votype = 'VideoWriter'; %Record the Exploration to view it again
vo = VideoWriter('Data Exploration Video', 'MPEG-4');
set(vo, 'FrameRate', 5);
open(vo);
for i = 1:NoOfFailureModes
NoOfDataPoints = height(data{i});
x = zeros(L*NoOfDataPoints,0);
y = zeros(L*NoOfDataPoints,0);
z = zeros(L*NoOfDataPoints,0);
figure;
set(gcf,'Visible','on')
for j = 1:NoOfDataPoints
data{i}.X_FFT(j,:) = computeFFT(data{i}.X(j,:)-mean(data{i}.X(j,:)),L);
data{i}.Y_FFT(j,:) = computeFFT(data{i}.Y(j,:)-mean(data{i}.Y(j,:)),L);
data{i}.Z_FFT(j,:) = computeFFT(data{i}.Z(j,:)-mean(data{i}.Z(j,:)),L);
x((j-1)*L+1 : j*L) = data{i}.X(j,:);
y((j-1)*L+1 : j*L) = data{i}.Y(j,:);
z((j-1)*L+1 : j*L) = data{i}.Z(j,:);
t = (1:j*L)*convertToMinutes;
subplot(3,2,1);
plot(t,x);
title({"Experiment: " + num2str(i) , "Time Domain"});
xlabel("time (min.)",'FontWeight','bold');
ylabel("X",'rotation',0,'FontWeight','bold');
subplot(3,2,2);
bar(f,data{i}.X_FFT(j,:));
title({"Sample: " + num2str(j) + "; Label: " + char(data{i}.Label(j)), "Frequency Domain"});
xlabel("frequency (Hz)",'FontWeight','bold');
ylabel("X",'rotation',0,'FontWeight','bold');
subplot(3,2,3);
plot(t,y);
xlabel("time (min.)",'FontWeight','bold');
ylabel("Y",'rotation',0,'FontWeight','bold');
subplot(3,2,4);
bar(f,data{i}.Y_FFT(j,:));
xlabel("frequency (Hz)",'FontWeight','bold');
ylabel("Y",'rotation',0,'FontWeight','bold');
subplot(3,2,5);
plot(t,z);
xlabel("time (min.)",'FontWeight','bold');
ylabel("Z",'rotation',0,'FontWeight','bold');
subplot(3,2,6);
bar(f,data{i}.Z_FFT(j,:));
xlabel("frequency (Hz)",'FontWeight','bold');
ylabel("Z",'rotation',0,'FontWeight','bold');
drawnow;
writeVideo(vo, getframe(gcf));
end
end
close(vo);
%%
%%
%Helper Functions
function P1 = computeFFT(X,L)
Y = fft(X);
P2 = abs(Y/L);%absolute value
P1 = P2(1:L/2+1)
P1(2:end-1) = 2*P1(2:end-1);
end
%%

Iniciar sesión para comentar.

Más respuestas (1)

Cris LaPierre
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:
Error using strsplit (line ##)
First input must be either a character vector or a string scalar.
  4 comentarios
Aniket Manjare
Aniket Manjare el 19 de Dic. de 2020
Please find the data set for 6 fields,
Please help me solve this problem, i have tried alot, mistakenly i have previously loaded the wrong data set
Here i have attached the file
  1. Labelling.m
  2. dataset1.csv
  3. dataset2.csv

Iniciar sesión para comentar.

Comunidades de usuarios

Más respuestas en  ThingSpeak Community

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by