array manipulation using location
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    SSG_newbiecoder
      
 il 25 Dic 2017
  
    
    
    
    
    Modificato: SSG_newbiecoder
      
 il 26 Dic 2017
            Hello, I have an array X and another array Y which has some of the indices in array X. I need a new array which will have the X value in the corresponding Y element(index location in X) and zero otherwise. can anybody help me? this is what I tried but it's not working. I'm only getting one value.
X=[11 22 51 28 93 11 124 153 165 176 17 18 19 20];
iY=[1 3 5 9];
for m=1:length(X)
    for n=1:length(iY)
    if m~=iY(n)
        combined_matrix(m)=0;
    elseif m==iY(n)
        combined_matrix(m)=X(iY(n));
    end
      end
  end
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

