[Reddit Cross Post] Filtering results with small divergence
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Toshiaki Takeuchi
il 15 Ott 2025 alle 17:06
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 Commenti
Risposta accettata
Sam Chak
il 17 Ott 2025 alle 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Historical Contests in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!