can any one please help me with the code? I am not getting the proper values of s.
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Gaurav Sharma
 am 27 Okt. 2018
  
    
    
    
    
    Bearbeitet: Image Analyst
      
      
 am 27 Okt. 2018
            it is showing me the following error: "Unable to perform assignment because the left and right sides have a different number of elements.
Error in hw8 (line 16) s(t)=sign(k);"
0 Kommentare
Akzeptierte Antwort
  Image Analyst
      
      
 am 27 Okt. 2018
        
      Bearbeitet: Image Analyst
      
      
 am 27 Okt. 2018
  
      Because i1 and i2 are vectors, k is a vector, but t is not. You can't stuff a bunch of numbers into an array slot meant for a single number.
Perhaps you wanted this:
% w1= input('value of w1= ');
% w2= input('value of w2= ');
% T= input('value of threshold value= ');
s = zeros(4,1);
w1 = 1.5; 
w2 = 1.5;  
T = 1;
i1 = [0 0 1 1];
i2 = [0 1 0 1];   
for y = 1 : length(i1)  
  k = (w1 * i1(y) + w2 * i2(y)) - T;  
  s(y) = sign(k);
end
s
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

