i have (y) with size of 784*1000 and i mapped this y to get gex, gin , but the result shown only 1 dimension and i want that mapping for the two dimension (784*1000),
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Hagar Hendy
 el 20 de Nov. de 2022
  
    
    
    
    
    Comentada: Hagar Hendy
 el 21 de Nov. de 2022
            i have (y) with size of 784*1000 and i mapped this y to get gex, gin , but the result shown only 1 dimension and i want that mapping for the two dimension (784*1000),
Rmin = 1e5
Rmax = 1e6
Gmin = 1.0/Rmax
Gmax = 1.0/Rmin
Input =table2array(in)
y=w{1}
 for i = 1:length(y)
      if y(i)>=0
          gex(i) = Gmax*y(i) +Gmin*(1-y(i))
          gin(i) =Gmin
          disp(y(i))
          disp (gex(i))
      else
          gex(i) =Gmin
          gin(i) = -Gmax*y(i) +Gmin*(1+y(i))
      end 
 end
0 comentarios
Respuesta aceptada
  Voss
      
      
 el 20 de Nov. de 2022
        
      Editada: Voss
      
      
 el 20 de Nov. de 2022
  
      Initialize gex and gin to be matrices the same size as y.
Then loop over all elements of y:
gex = zeros(size(y));
gin = zeros(size(y));
for i = 1:numel(y) % numel(y), not length(y)
    if y(i)>=0
        gex(i) = Gmax*y(i) +Gmin*(1-y(i));
        gin(i) = Gmin;
    else
        gex(i) = Gmin;
        gin(i) = -Gmax*y(i) +Gmin*(1+y(i));
    end
end
or use logical indexing instead of a loop:
gex = zeros(size(y));
gin = zeros(size(y));
idx = y >= 0;
gex(idx) = Gmax*y(idx) + Gmin*(1-y(idx));
gin(idx) = Gmin;
gex(~idx) = Gmin;
gin(~idx) = -Gmax*y(~idx) + Gmin*(1+y(~idx));
3 comentarios
  VBBV
      
      
 el 21 de Nov. de 2022
				May be you mean the Input as below
Input * gex 
instead of
input * gex  % input is standard Matlab function
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!