rearrange the G matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear
I plot each point in freq. domain and I did ifft.
f=0:1/1024:1;
t=0:1/1024:1;
a=10;
for i=1:1025
if f(i)>=25/1024 && f(i)<=100/1024
v(i)=a;
else
v(i)=0;
end
end
figure;
plot(f,v);
for i=1:1025
G(i)=0;
for j=1:1025
G(i)=v(j).*cos(i*j*2*pi/1025)+G(i);
end
end
figure;
plot(t,G)
Now I would like to rearrange the G matrix so that the last half of points are put as the first half and the first half as the last half (i.e. the biggest point is now in the middle.
regards
Dhafer
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 13 Août 2012
add this code
n=floor(size(G,2)/2)
if n==size(G,2)/2
out(1:n)=G(n+1:end);out(n+1:2*n)=G(1:n)
else
out(1:n)=G(n+2:end);
out(n+1:2*n+1)=G(1:n+1);
end
figure;plot(t,out)
Note: in your case length(G)=1025 is odd, i added a test when it's even
0 commentaires
Plus de réponses (2)
Andrei Bobrov
le 13 Août 2012
n = numel(G);
k = floor(n/2);
p = ceil(n/2)+~rem(n,2);
G([1:k,p:end]) = G([p:end,1:k]);
0 commentaires
Voir également
Catégories
En savoir plus sur Graphics Object Programming 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!