how to skip and not add to matrix
    1 visualizzazione (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    liu James
 il 27 Giu 2017
  
    
    
    
    
    Modificato: Geoff Hayes
      
      
 il 27 Giu 2017
            When performing an intersect function there will be times where the value of D=[] since it doesn't exist in date2. In this case I would like to skip adding the values into the array. I tried this way, but it seems to not want to skip to the next increment value and still add to the array. How can I make it skip if D=[].
for i=1:49
      [D,ia,ib]=intersect(date1(i),date2)
      if D==[]
          p=1
      else    
      E(end+1,:)=[D,CUAB(i),CUSB(ib)]
      end 
  end
0 Commenti
Risposta accettata
  Geoff Hayes
      
      
 il 27 Giu 2017
        
      Modificato: Geoff Hayes
      
      
 il 27 Giu 2017
  
       if ~isempty(D)
    E(end+1,:)=[D,CUAB(i),CUSB(ib)];
 end
Note that if you try to evaluate
 D == []
then the answer is
 ans =
    []
Since this is not the true logical, then your code will always evaluate the else body of your if/else code.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Cell Arrays 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!

