Simulink Embedded MATLAB Function

I have tried to introduce the next function in MATLAB embedded function:
function [R2, A2, Fi2, sigma2,fk2,w2] = proof(N, fhz, t, K,tao, sE) %#codegen
[ll,kk]=size(sE);
A1=zeros(ll,kk); R1=zeros(ll,kk);
fk1=zeros(ll,kk); Fi1=zeros(ll,kk); sigma1=zeros(ll,kk);
g=0;c=1; sE1=zeros(ll,kk); for s=N+1:length(sE) d=1;
for r=c:N+g
sE1(d)=sE(r);
d=d+1;
end
c=c+1;
[R, sigma, w, fk]=pronyF2(sE1,tao);
R1 = R(1)*exp(-1i*2*pi*fhz*t(s)); % Guardar vector de cada fasor rotado A1(s,:) = abs(R1); % Guardar vector de Amplitud Fi1(s,:) = angle(R1); % Guardar vector cada ¡ngulo sigma1(s)=sigma; % Guardar vector de cada Amortiguamiento fk1(s,:)=fk(1); % Guardar vector de cada frecuencia w1(s,:)=w(1);
g=g+1;
end
R2=R1; A2=A1; Fi2=Fi1; sigma2=sigma1; fk2=fk1; w2=w1;
%C·lculo de los coeficientes del Modelo de PredicciÛn Lineal (LPM) ____________________________________________________________________________
function [R,sigma,w,fk] =pronyF2(sE1, tao) [ll,kk]=size(sE1'); K=1; n=2*K; Y=zeros(ll,kk); q=zeros(ll); N=5; for m=1:N-2 g=1; K=1; o=1;
for o=1:2*K
Y(m,o)= sE1(n+1-g);
g=g+1;
end
n=n+1;
end
K=1;
n=2*K;
h=1;
for k=n+1:N
q(h)=sE1(k);
h=h+1;
end
a1=pinv(Y)*q';
% Segundo paso: C·lculo de RaÌces del polinomio caracterÌstico
P=[1 -a1'];
z=roots(P);
%%Tercer paso: C·lculo de Magnitudes y ·ngulos de la seÒal estimada
Z=complex(zeros(ll,kk));
for u=1:N
for v=1:length(z)
Z(u,v)= z(v,1)^(u-1);
end
end
R= 2*pinv(Z)*(sE1'); sigma=(real(log(z)))/tao; w=angle(z)/tao; fk=(w/(2*pi));
%%Tercer paso: C·lculo de Magnitudes y ·ngulos de la seÒal estimada
Z=complex(zeros(ll,kk));
for u=1:N
for v=1:length(z)
Z(u,v)= z(v,1)^(u-1);
end
end
R= 2*pinv(Z)*(sE1'); sigma=(real(log(z)))/tao; w=angle(z)/tao; fk=(w/(2*pi)); ____________________________________________________________________________ When i press to Run the simulink stop and begin the debugger. This MATLAB function must take whatever signal and perform an estimation in the function pronyF2, then, give these results to R, sigma,w and fk. With this function, we use the function proof to calculate [R2, A2, Fi2, sigma2,fk2,w2]. I don't know what is the problem?, i'm beginner in simulink using matlab function.
Thank you for your help!!

댓글 수: 1

Kaustubha Govind
Kaustubha Govind 2013년 7월 26일
If Simulink opened the debugger, it usually means that there is a run-time error in your code. You might want to step through your code when the debugger opens to see which line errors out.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

제품

질문:

2013년 7월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by