Required a mathematical logic.!
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Nimisha
 am 11 Jul. 2016
  
    
    
    
    
    Bearbeitet: Image Analyst
      
      
 am 11 Jul. 2016
            A = [1 0 1 0 0 0 1 1 1 0  1  0  1  0  1  1  1  0  0  1];
B = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19];
I want a logic in which when A will be 1 as input, then output should be respective from B, But when input A comes as 0, then previous output of B should be followed when A were 1. I tried various if.. else loops and while loop, but not getting proper output! I also tried by simulink Pulse generator and clock"
0 Kommentare
Akzeptierte Antwort
  James Tursa
      
      
 am 11 Jul. 2016
        
      Bearbeitet: James Tursa
      
      
 am 11 Jul. 2016
  
      E.g., using a simple loop:
result = zeros(size(B));
c = B(1); % Covers the case when A(1) = 0
n = numel(B);
for k=1:n
    if( A(k) == 1 )
        c = B(k);
    end
    result(k) = c;
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Annotations finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

