[Reddit Cross Post] Filtering results with small divergence
    28 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Toshiaki Takeuchi
    
 el 15 de Oct. de 2025 a las 17:06
  
    
    
    
    
    Respondida: Sam Chak
      
      
 el 17 de Oct. de 2025 a las 8:41
            Hello, I am currently working on a calculator for composite materials, due to the nature of composite materials, they have different mechanical properties regarding their respective angle when plied together. I am trying to filter the plies that have similar mechanical properties so I can extract them for my work. Example if Q1=100, Q2=100,1 Q3=100,5 Q4=200 Q5=205. The plies Q1,Q2,Q3 are similar and processing them in my further calculations creates an excessive computational strain that is not needed. How can I code the program to choose the Q3,Q4,Q5 values and discard the other ones? Any tip, video or anything else will be greatly appreciated. Thank you in advance!
0 comentarios
Respuesta aceptada
  Sam Chak
      
      
 el 17 de Oct. de 2025 a las 8:41
        Are you looking for something like this
% Case 1
Q   = [100 100 100 200 205];
Qu  = unique(Q)
or something like this?
% Case 2
rng('default')
objfun    = @(x) ((x - 100).*(x - 200).*(x - 205) + rand/1e4).^2;
options   = optimoptions(@ga,'PopulationSize', 30, 'MaxGenerations', 60, 'Display', 'off');
for i = 1:5
    xSol(i) = ga(objfun, 1, [], [], [], [], 0, 300, [], options);
end
disp(xSol)
Xsol  = [100, 200, 205];
for j = 1:numel(xSol)
    TF  = isapprox(xSol(j), Xsol, AbsoluteTolerance=2e-2);
    if sum(TF) == 1
        Q(j) = xSol(j);
    else
        Q(j) = 0;
    end
end
Q_solution = Q(Q ~= 0);
disp(Q_solution)
round(Q_solution)
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Historical Contests 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!

