find minimum over a range of indices
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
Dear matlab community i want to calculate indices of min_values of ranges of data in a lengthy array for the following case;
I am modeling a rotating fan blade. i want to detect the blade tip in real time on difrnt positions by lasers installed at outer circumference of the fan. logic is simple: there are (x,y) coords of sensors, and of blade tip (x_tip, y_tip) . when euclidean distance b/w these tip and sensor coords are minimum (happens once every rotation) then they coincide and that time step is the time of arrival (TOA) or detection time for that specific sensor. sample code is:
t_tot=62.5;    t_stp=0.5;   t_vec=0:t_stp:t_tot;        % simulation time (s).
  rot=[1:1:7];                                          % # of rotations
  N=18; 
  rot = reshape(repmat(rot(:).',N,1),1,[])';        %let each rotatn cmplts in 18 t_stps.
  [rot_num, rot_indx] = unique(rot,'first');                  % indices for each rotation
  rot_indx(end+1,1)=find(rot == rot(numel(rot)), 1, 'last');    % index of last value of rotation
    N_sens=4; separation=pi/3;                                % # of sensors to detct blade tip.
    theta_sens=pi/3:separation:N_sens*separation;              % Sensors' postions
    x_sens=L.*cos(theta_sens);  y_sens=L.*sin(theta_sens);       % (x,y) coords of sensors
    theta_inst=linspace(0,rot(end)*2*pi,numel(t_vec))';        %ang_positn of tip @any t_stp
    x_tip=L.*cos(theta_inst); y_tip=L.*sin(theta_inst);          %tip coords
     Eucl_Dist=(((x_tip-x_sens).^2)+(y_tip-y_sens).^2).^0.5;   % euclidean distances of 
                                                            %blade tip from all the sensors over whole simulation time
here Eucl_Dist size is 126(t_stps)*4(sensors). there are 7 rotations in total. so Eucl_dist need to broken into 7 matrices of m*4 size. where m is indices range over which a rotation persists. and index of minimum over each column of each rotation data need to be found. time value of that index is the TOA, so in each rotation at a certain index, TOA(index(rotation(i),:))=time(index(min(Eucld_dist))); TOA size be length(rot)*N_sens, here 126*4. with non-zero values at min(Eucld_dist). I hope i dint make it too confusing. I tried different loop approaches but its not promising. A vectorized approach will be appreciated.
1 comentario
Respuestas (1)
  KALYAN ACHARJYA
      
      
 el 20 de Sept. de 2018
        
      Editada: KALYAN ACHARJYA
      
      
 el 20 de Sept. de 2018
  
      As per the title of the question, I have answered here, as mentioned range of the indices
min_data=min(data,[],'all') calculates the minimum over all elements of data.
1 comentario
  kamal wisal
 el 21 de Sept. de 2018
				
      Editada: kamal wisal
 el 21 de Sept. de 2018
  
			
		Ver también
Categorías
				Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!