Borrar filtros
Borrar filtros

Hello, facing a problem on running first part of the program showing the given error ; i also add the 2nd part of this program and 2nd para and errors too.

1 visualización (últimos 30 días)
function [EPClist,data]=extraction_data(Nomfichier)
dummy=readtable(Nomfichier);
%importfile
j=1;
for i=1:height(dummy)
if strtrim(dummy.OperationResult(i))=="Read OK"
%dummy.OperationResult(i)==" Read OK"
%' Read OK'
data_raw(j,1)=dummy.Date(i);
data_raw(j,2)=dummy.EPC(i);
data_raw(j,3)=dummy.ReadData(i);
j=j+1;
end
end
clear dummy
EPClist=unique(data_raw(:,2));
Nb_capteur=length(EPClist);
data=cell(1,Nb_capteur);
for i=1:Nb_capteur
k=1;
for j=1:length(data_raw)
if data_raw(j,2)==EPClist(i)
%data{i}(k,1)=data_raw(j,1);
%data{i}(k,1)=0;
data{i}(k,1)=hex2dec(data_raw{j,3}(5:8));
temphexa=data_raw{j,3}(9:12);
if temphexa(1)=='F'
data{i}(k,2)=1/100*(hex2dec(temphexa)-hex2dec('FFFF')+1);
else
data{i}(k,2)=1/100*hex2dec(temphexa);
end
k=k+1;
end
end
EPClist{i}=EPClist{i}(end-3:end);
end
data extraction program:
clear
clc
close all
%données d'entrée 7534 - campagne controle calibration après campagne ISE
%AZUL - Run5 define the presure
table_pression{1}=[...
20;75;180;240;300;480;400;270;210;150 ;...
20;75;180;240;300;480;400;270;210;150 ;...
20;75;180;240;300;480;400;270;210;150 ;...
20;75;180;240;300;480;400;270;210;150 ;...
20;75;180;240;300;480;400;270;210;150 ;...
20;75;180;240;300;480;400;270;210;150 ];
% The points which we dont want to see...
table_delete=[1 317;1049 1549;2290 2796;3521 4027;4767 5291;6014 6511;7243 10000];
% Defining train file for sending the trains
titre='C:\Users\FX625040\Documents\Stage\Scripts Matlab\PresSense\data_log\capteur_7520_2023-01-09.xlsx';
%% data extract
%The function is to extract palier where the pressure and temprature EPC (eular
%pole parameters?)calling the functions detec palier and the output are
%EPC,pressure;temprature
[EPC,pression,temperature]=detect_palier(titre,table_delete);
%% traitement de toutes les données
num_sensor=length(EPC);
for sens=1:num_sensor
%% palier extract
clearvars data temp n_palier indice_palier palier_extract SYNTH_RES X Y Z
data=pression{sens};
temp=temperature{sens};
n_palier=ones(1,length(data));
current_palier=1;
indice_palier(1,1)=1;
% Ancienne fonction de détection de palier
% for i=2:length(data)
% if (data(i)>data(i-1)+5) || (data(i)<data(i-1)-5)
% current_palier=current_palier+1;
% indice_palier(current_palier-1,2)=i-1;
% indice_palier(current_palier,1)=i;
% end
% n_palier(i)=current_palier;
% end
% Nouvelle fonction de détection de palier
% new functions to detection of palier
for i=2:length(data)
if (data(i)>data(i-1)+300) || (data(i)<data(i-1)-300)
current_palier=current_palier+1;
indice_palier(current_palier-1,2)=i-1;
indice_palier(current_palier,1)=i;
end
n_palier(i)=current_palier;
end
nb_palier=max(n_palier);
indice_palier(nb_palier,2)=length(data);
% plot figure
f=figure('Name',strcat(EPC{sens},'_paliers_extraits'),'units','normalized','outerposition',[0 0 1 1]);
clear ha
ha(1)=subplot (3,1,1);
plot(data,'-o')
ha(2)=subplot (3,1,3);
plot(temp)
ha(3)=subplot (3,1,2);
plot(n_palier,'-')
linkaxes(ha,'x');
ylabel(ha(1),'ratio (µV/V)');
ylabel(ha(2),'temperature (°C)');
ylabel(ha(3),'# palier')
xlabel(ha(3),'# sample')
% for saving the graph
saveas(f,strcat('.\results\graphes\SN',EPC{sens},'_paliers_extraits.png'))
%%Palier moyenné sur la plage stable
% for i=1:nb_palier
% palier_extract(i,1)=(mean(data(indice_palier(i,1):indice_palier(i,2))))/1000000;
% palier_extract(i,2)=mean(temp(indice_palier(i,1):indice_palier(i,2)));
% end
%% palier = le dernier point seulement
for i=1:nb_palier
palier_extract(i,1)=data(indice_palier(i,2))/1000000;
palier_extract(i,2)=temp(indice_palier(i,2));
end
%%
% table_pression_bar=table_pression{sens};
% table_pression_psi=table_pression_bar*14.503773800721815;
table_pression_psi=table_pression{sens};
%% new figure for new paliers
f=figure('Name',strcat(EPC{sens},'_paliers_extraits2'),'units','normalized','outerposition',[0 0 1 1]);
clear ha
ha(1)=subplot (2,1,1);
plot(palier_extract(:,1),'o')
ha(2)=subplot (2,1,2);
plot(palier_extract(:,2),'o')
linkaxes(ha,'x');
ylabel(ha(1),'ratio (µV/V)');
ylabel(ha(2),'temperature (°C)');
saveas(f,strcat('.\results\graphes\SN',EPC{sens},'_paliers_extraits2.png'))
%% Fit
%[FCT_COR,GOF,OUTPUT]=fit([T,alpha],P,'polytype')
X=palier_extract(:,2);
Y=palier_extract(:,1);
Z=table_pression_psi;
%% Exploitation résultats fit poly21
[FCT_COR,GOF,OUTPUT]=fit([X,Y],Z,'poly31');
Res_max=max(abs(OUTPUT.residuals));
Res_moy=mean(OUTPUT.residuals);
SYNTH_RES{1,1}='SN Capteur';
SYNTH_RES{1,2}='Polynome';
SYNTH_RES{1,3}='';
SYNTH_RES{1,4}='Résidu max';
SYNTH_RES{1,5}='Résidu moy';
SYNTH_RES{1,6}='R²';
SYNTH_RES{1,7}='Erreur standard';
SYNTH_RES{3,3}='Valeur hexa à inscrire';
SYNTH_RES{2,1}=EPC{sens};
SYNTH_RES{2,2}='p00+p01*x+p10*y+p11*x*y+p20*x^2';
SYNTH_RES{2,4}=Res_max;
SYNTH_RES{2,5}=Res_moy;
SYNTH_RES{2,6}=GOF.rsquare;
SYNTH_RES{2,7}=GOF.rmse;
POLY_NAMES=coeffnames(FCT_COR);
POLY_VALUES=coeffvalues(FCT_COR);
for m=1:length(POLY_NAMES)
SYNTH_RES{m+3,1}=POLY_NAMES{m};
SYNTH_RES{m+3,2}=POLY_VALUES(m);
end
% SYNTH_RES{4,3}=strcat('''',dec2hex(round(-POLY_VALUES(1)*100),4));
% SYNTH_RES{5,3}=strcat('''',dec2hex(round(POLY_VALUES(2)*1000000),4));
% SYNTH_RES{6,3}=strcat('''',dec2hex(round(POLY_VALUES(3)),4));
% SYNTH_RES{7,3}=strcat('''',dec2hex(round(POLY_VALUES(4)*100),4));
SYNTH_RES{length(POLY_NAMES)+5,1}='Pression banc (psi)';
SYNTH_RES{length(POLY_NAMES)+5,2}='Température';
SYNTH_RES{length(POLY_NAMES)+5,3}='Ratio';
SYNTH_RES{length(POLY_NAMES)+5,4}='Residu';
SYNTH_RES{length(POLY_NAMES)+5,5}='Pression corrigée (psi)';
SYNTH_RES{length(POLY_NAMES)+5,6}='Pression saturée (psi)';
for i=1:length(table_pression_psi);
SYNTH_RES{length(POLY_NAMES)+5+i,1}=table_pression_psi(i);
SYNTH_RES{length(POLY_NAMES)+5+i,2}=palier_extract(i,2);
SYNTH_RES{length(POLY_NAMES)+5+i,3}=palier_extract(i,1);
SYNTH_RES{length(POLY_NAMES)+5+i,4}=OUTPUT.residuals(i);
SYNTH_RES{length(POLY_NAMES)+5+i,5}=FCT_COR(palier_extract(i,2),palier_extract(i,1));
SYNTH_RES{length(POLY_NAMES)+5+i,6}=FCT_COR(palier_extract(i,2),15625/1000000);
end
xlswrite(strcat('.\results\poly21\SN',EPC{sens},'_synthese_p21.xlsx'),SYNTH_RES,1);
% f=figure('Name',strcat(EPC{sens},'_pression_sat_bar'),'units','normalized','outerposition',[0 0 1 1]);
% clear ha
% ha=plot(palier_extract(:,2),FCT_COR(palier_extract(:,2),15625/1000000)/14.503773800721815);
% ylabel('pression de saturation (bar)');
% xlabel('temperature')
% saveas(f,strcat('.\results\graphes\poly21\SN',EPC{sens},'_pression_sat_bar.png'))
f=figure('Name',strcat(EPC{sens},'_residus'),'units','normalized','outerposition',[0 0 1 1]);
clear ha
ha=plot(FCT_COR,[X,Y],Z,'Style','Residuals');
ylabel('pression (µV/V)');
xlabel('temperature (°C)');
zlabel('residus (psi)');
view([0 -1 0])
saveas(f,strcat('.\results\graphes\poly21\SN',EPC{sens},'_residus_p21.png'))
%% Exploitation résultats fit poly11
% a polynomial regression on a set of data points (X,Y,Z)
clearvars SYNTH_RES FCT_COR GOF OUTPUT;
[FCT_COR,GOF,OUTPUT]=fit([X,Y],Z,'p00+p10*x+p01*y+p11*x*y');
Res_max=max(abs(OUTPUT.residuals));
Res_moy=mean(OUTPUT.residuals);
SYNTH_RES{1,1}='SN Capteur';
SYNTH_RES{1,2}='Polynome';
SYNTH_RES{1,3}='';
SYNTH_RES{1,4}='Résidu max';
SYNTH_RES{1,5}='Résidu moy';
SYNTH_RES{1,6}='R²';
SYNTH_RES{1,7}='Erreur standard';
SYNTH_RES{3,3}='Valeur hexa à inscrire';
SYNTH_RES{2,1}=EPC{sens};
SYNTH_RES{2,2}='p00+p10*x+p01*y+p11*x*y';
SYNTH_RES{2,4}=Res_max;
SYNTH_RES{2,5}=Res_moy;
SYNTH_RES{2,6}=GOF.rsquare;
SYNTH_RES{2,7}=GOF.rmse;
POLY_NAMES=coeffnames(FCT_COR);
POLY_VALUES=coeffvalues(FCT_COR);
for m=1:length(POLY_NAMES)
SYNTH_RES{m+3,1}=POLY_NAMES{m};
SYNTH_RES{m+3,2}=POLY_VALUES(m);
end
% SYNTH_RES{4,3}=strcat('''',dec2hex(round(-POLY_VALUES(1)*100),4));
% SYNTH_RES{5,3}=strcat('''',dec2hex(round(POLY_VALUES(2)),4));
% SYNTH_RES{6,3}=strcat('''',dec2hex(round(POLY_VALUES(3)*1000000),4));
% SYNTH_RES{7,3}=strcat('''',dec2hex(round(POLY_VALUES(4)*100),4));
SYNTH_RES{length(POLY_NAMES)+5,1}='Pression banc (psi)';
SYNTH_RES{length(POLY_NAMES)+5,2}='Température';
SYNTH_RES{length(POLY_NAMES)+5,3}='Ratio';
SYNTH_RES{length(POLY_NAMES)+5,4}='Residu';
SYNTH_RES{length(POLY_NAMES)+5,5}='Pression corrigée (psi)';
SYNTH_RES{length(POLY_NAMES)+5,6}='Pression saturée (psi)';
for i=1:length(table_pression_psi)
SYNTH_RES{length(POLY_NAMES)+5+i,1}=table_pression_psi(i);
SYNTH_RES{length(POLY_NAMES)+5+i,2}=palier_extract(i,2);
SYNTH_RES{length(POLY_NAMES)+5+i,3}=palier_extract(i,1);
SYNTH_RES{length(POLY_NAMES)+5+i,4}=OUTPUT.residuals(i);
SYNTH_RES{length(POLY_NAMES)+5+i,5}=FCT_COR(palier_extract(i,2),palier_extract(i,1));
SYNTH_RES{length(POLY_NAMES)+5+i,6}=FCT_COR(palier_extract(i,2),15625/1000000);
end
xlswrite(strcat('.\results\poly11\SN',EPC{sens},'_synthese_p111.xlsx'),SYNTH_RES,1);
% xlswrite(strcat('C:\Users\FX625040\Documents\Stage\Scripts Matlab\P0',EPC{sens},'_synthese_p11.xlsx'),SYNTH_RES,1);
% f=figure('Name',strcat(EPC{sens},'_pression_sat_bar'),'units','normalized','outerposition',[0 0 1 1]);
% clear ha
% ha=plot(palier_extract(:,2),FCT_COR(palier_extract(:,2),15625/1000000)/14.503773800721815);
% ylabel('pression de saturation (bar)');
% xlabel('temperature')
% saveas(f,strcat('.\results\graphes\poly11\SN',EPC{sens},'_pression_sat_bar.png'))
f=figure('Name',strcat(EPC{sens},'_residus'),'units','normalized','outerposition',[0 0 1 1]);
clear ha
ha=plot(FCT_COR,[X,Y],Z,'Style','Residuals');
ylabel('pression (µV/V)');
xlabel('temperature (°C)');
zlabel('residus (psi)');
view([0 -1 0])
saveas(f,strcat('.\results\graphes\poly11\SN',EPC{sens},'_residus_p11.png'))
end
error :
Warning: Variable names were modified to make them valid MATLAB identifiers. The original names are saved in the
VariableDescriptions property.
Undefined operator '==' for input arguments of type 'cell'.
Error in extraction_data (line 26)
if data_raw(j,2)==EPClist(i)
Error in detect_palier (line 3)
[EPC,B]=extraction_data(titre);
Error in extract_palier (line 23)
[EPC,pression,temperature]=detect_palier(titre,table_delete);

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 25 de Abr. de 2023
Editada: Cris LaPierre el 25 de Abr. de 2023
The current error is that you cannot compare using '==' with a cell. The solution is likely as simple as using curly braces instead fo parentheses, assuming that the cell element is a scalar. We can't test because we do not have your data file.
A = {2}
A = 1×1 cell array
{[2]}
% using {} to extract data from the cell
A{1} == 2
ans = logical
1
% your error caused because () returns a cell
A(1)==2
Operator '==' is not supported for operands of type 'cell'.

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by