How do you set every other row as well as every other column to zero?
    15 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
Using a phantom...
P = phantom('Modified Shepp-Logan',256);
And plotting it with a fourier transform
n = 256;
Fp = fft2(P,n,n);
How would I remove certain rows and columns?
0 commentaires
Réponse acceptée
  Dave B
    
 le 16 Nov 2021
        
      Modifié(e) : Dave B
    
 le 16 Nov 2021
  
      To remove every other column, set it to empty. You can do "every other" generally using A:2:B where A is the first value and B is the last value, and you can stick this in as an index.
a=reshape(1:25,5,5)
a1=a;
a1(1:2:end,:)=[] % remove every other row
a2=a;
a2(2:2:end,:)=[] % remove every other row starting at the second row
a3=a;
a3(:,1:2:end)=[] % remove every other column
a4=a;
a4(:,1:2:end)=0 % set every other row/column to 0
% If you really feel like you have to do both at once, you can. But it
% would be much easier to just do rows and columns sequentially.
a5=a;
[r,c]=meshgrid(1:size(a5,1),1:size(a5,2));
ind=sub2ind(size(a5),r(mod(r,2)==0 | mod(c,2)==0),c(mod(r,2)==0 | mod(c,2)==0));
a5(ind)=0
0 commentaires
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Read, Write, and Modify Image 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!

