rearrange the G matrix
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Azzi Abdelmalek
2012-8-13
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 个评论
更多回答(2 个)
Andrei Bobrov
2012-8-13
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!