finding a number in the vector equal or around a desired number
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Othman Alkandri
el 30 de Dic. de 2022
Comentada: Othman Alkandri
el 2 de En. de 2023
I am trying to the from dleta_A vector a number equal to 3.1528 or two numbers rounded up and down for the desired number
V_breadth = 12;
d_Vd = 0:0.005:2;
V_Draft_min = 0.5;
V_breadth_min = 0.4*V_breadth;
V_breadth_max = 0.8*V_breadth;
for i = 1:1:length(d_Vd)
V_Draft_new(i) =V_Draft_min+ d_Vd(i);
tan_theta = (V_Draft - V_Draft_min )/(0.5*(V_breadth_max-V_breadth_min));
Vb(i) = V_breadth_min + (d_Vd(i).*(2/tan_theta));
dleta_A(i) = (V_breadth_min+ Vb(i)) *d_Vd(i)/2;
end
V_Draft_new
Vb
dleta_A
0 comentarios
Respuesta aceptada
Image Analyst
el 30 de Dic. de 2022
Try this
% Create sample data
dleta_A = 4 * rand(1, 1000)
% Find element of dleta_A that is closest to 3.1528.
differences = abs(dleta_A - 3.1528);
[minDifference, indexOfMin] = min(differences)
closestValue = dleta_A(indexOfMin)
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots 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!