Why doesn't this drawnow work?
Afficher commentaires plus anciens
I want to show the evolution of the convolution operation between two signals through time. I represent the movement in each step with a drawnow. But the last one, the convolution one, doesn't draw through time; it just moves its Y axis up and down, following what would be the line that define the convolution.
I mean: if the answer is this, for example:

the Y axis central point goes like: 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 3, 2.5, 2, 1.5, 1, 0.5 and 0. And what I finally obtain is this:

All the steps, except the last one, work perfectly (at least that's what I think). But this issue is driving me crazy!
This is my main program:
x1=[-4:0.5:4];
f1=[zeros(1,5) ones(1,7) zeros(1,5)];
g1=[zeros(1,5) ones(1,7) zeros(1,5)];
conv1=convolucion_e(f1,g1,x1)
This is the convolution function:
function [h2]=convolucion_e(f,g,x)
%Representación de f y g
figure(1)
subplot(2,5,1)
plot(x,real(f),'c'), legend('Real[f(x)]')
subplot(2,5,6)
plot(x,imag(f),'g'), legend('Imag[f(x)]')
figure(1)
subplot(2,5,2)
plot(x,real(g),'c'), legend('Real[g(x)]')
subplot(2,5,7)
plot(x,imag(g),'g'), legend('Imag[g(x)]')
%Abatimiento de g
g2=fliplr(g)
figure(1)
subplot(2,5,3)
plot(x,real(g2),'r'), legend('Real[g(-x'')]')
subplot(2,5,8)
plot(x,imag(g2),'b'), legend('Imag[g(-x'')]')
h=zeros(1,length(g2));
figure(1)
%Desplazamiento de g2
for a=1:length(g2)
g3=circshift(g2,[1 a-((length(x))+1)/2]);
%Representación
subplot(2,5,4)
plot(x,real(g3),'b'), legend('Real[g(x-x'')]')
drawnow
subplot(2,5,9)
plot(x,imag(g3),'r'), legend('Imag[g(x-x'')]')
drawnow
%Multiplicación
h1=f.*g3;
%Integración
h_real(a)=integ_c(x,real(h1));
h_imag(a)=integ_c(x,imag(h1));
h2(a)=h_real(a)+j*h_imag(a);
subplot(2,5,5)
plot(x,real(h2(a)),'r'), legend('Real[h(x)]')
drawnow
subplot(2,5,10)
plot(x,imag(h2(a)),'b'), legend('Imag[h(x)]')
drawnow
end
figure(2)
subplot(2,1,1)
plot(x,real(h2)), legend('Parte real de la convolución')
subplot(2,1,2)
plot(x,imag(h2)), legend('Parte imaginaria de la convolución')
end
And finally what I get is this:

Thank you.
Réponses (0)
Catégories
En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!