Undefined variable error

Asked

Viewed 64 times

0

I have this code and it tells me that Spec is not defined in (pcolor(freq,tstart,Spec);colorbar), but I am calculating it in the cycle.. Does anyone understand why the mistake? Thank you!

N

size=N;%dimensão da Janela móvel
Nsize2=Nsize/2;
df=fNyq/Nsize2;
freq=[0:df:fNyq];
kw=0;
sw=zeros(Nsize,1);
tstart=tempo(1:Nsize:N-Nsize); %início da janela móvel
for k=1:Nsize:N-Nsize
    kw=kw+1;%Número da janela
    sw=radG(k+1:k+Nsize,NS+1);
    Fw=fft(sw);AFw=abs(Fw(1:Nsize2+1)/Nsize2);
    Spec(:,kw)=AFw
end

%fprintf(AFw)
%[nlin,ncol]=size(Spec);
figure(6);
pcolor(freq,tstart,Spec);colorbar
xlabel('f (Hz)');
ylabel('time start (s)')
figure; pcolor(periodo,tstart,Spec);colorbar
xlabel('T (s)');
ylabel('time start (s)')
  • Can you tell me which error message appears on the console?

  • The error is happening on which line? this " Spec(:,kw)=Afw" or this "pcolor(periodo,tstart,Spec)"? because I believe that you are trying to use the Spec inside the loop without first having declared it.

  • Appears in pcolor(periodo,tstart,Spec), and says " undifined 'Spec' "

  • Where is the variable period?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.