Matlab function implement. Don't work
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to work that function in simulink model but I get errors of size mismatch and more. First object define class..
function [location_fault,err]=fault(Iaa,Ibb,Icc)
%#eml
coder.extrinsic('wrcoef');
coder.extrinsic('legend');
coder.extrinsic('num2str');
coder.extrinsic('get_param');
coder.extrinsic('str2num');
coder.extrinsic('findpeaks');
coder.extrinsic('sortrows');
persistent d;
persistent di;
double location;
char actual_fault;
double locs;
double k;
double er;
double td;
double c;
b=([1/sqrt(3) 1/sqrt(3) 1/sqrt(3)
sqrt(2/3) -1/sqrt(6) -1/sqrt(6)
0 1/sqrt(2) -1/sqrt(2)]);
IM=b*[Iaa Ibb Icc]';
Ig=IM(1,:); % Ground mode (mode 0) signal
Ia1=IM(2,:); % Aerial mode (mode 1) signal
signal=Ig;
signal_length=length(signal);
di=[];
% Perform decomposition at level 'levels' of Signal using 'type' mother wavelet,
[c,l] = wavedec(signal',3,'db5');
for i=1:3
% Reconstruct detail coefficients at 'levels=i' from the wavelet decomposition structure [c,l]
cd=wrcoef('d',c,l,'db5',i);
di=[di;cd'];
end
k=0;
for i=3:-1:1;
k=k+1;
d(k,:)=di(i,:);
end
% Reconstruct approximation at 'levels',from wavelet decomposition structure [c,l].
a=wrcoef('a',c,l,'db5',3);
MulDWT=[a';d]; % the d matrix contains the levels of decomposition
details_1=d;
signal=Ia1;
signal_length1=length(signal);
di=[];
% Perform decomposition at level 'levels' of Signal using 'type' mother wavelet,
[c,l] = wavedec(signal',3,'db5');
for i=1:3
% Reconstruct detail coefficients at 'levels=i' from the wavelet decomposition structure [c,l]
cd=wrcoef('d',c,l,'db5',i);
di=[di;cd'];
end
k=0;
for i=3:-1:1;
k=k+1;
d(k,:)=di(i,:);
end
% Reconstruct approximation at 'levels',from wavelet decomposition structure [c,l].
a=wrcoef('a',c,l,'db5',3);
MulDWT=[a';d]; % the d matrix contains the levels of decomposition
details_2=d;
%plot(details_1(1,:))
%hold on
%plot(details_2(1,:))
%legend('Ground mode','Aerial Mode')
%for three-phase fault
details_2(1,end-40:end)=0;
[pks,locs] = findpeaks(details_2(1,:)); %from aerial mode where there are no reflections from the remote-end the ocation can be found directly
data=[pks',locs'];
[k]=sortrows(data,-1); %in descending order
td=k(2,2)-k(1,2);
location=((2.89*10^5)*td*10^-6)/2;
disp(['Fault Location = ' num2str(location) ' km']) ;
actual_fault=get_param('two_remotes/Distributed Parameters Line','Length');
k=str2num(actual_fault);
er=abs(location-k);
location_fault=location;
err=er;
end
I am not sure how to define the size or class.
1 commentaire
Astarag Chattopadhyay
le 8 Juin 2017
Hi,
Could you please explain in brief what functionality you are trying to accomplish through the above code and also provide the snapshots of the errors you are getting.
Réponses (0)
Voir également
Catégories
En savoir plus sur Continuous Wavelet Transforms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!