フィルターのクリア

finding a number in the vector equal or around a desired number

2 ビュー (過去 30 日間)
Othman Alkandri
Othman Alkandri 2022 年 12 月 30 日
コメント済み: Othman Alkandri 2023 年 1 月 2 日
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

採用された回答

Image Analyst
Image Analyst 2022 年 12 月 30 日
Try this
% Create sample data
dleta_A = 4 * rand(1, 1000)
dleta_A = 1×1000
1.3165 0.9536 1.6464 3.0427 3.4164 2.8714 2.8714 1.5470 3.9519 3.3921 2.2466 3.1289 2.5613 3.5461 3.0159 3.7663 3.6834 1.4579 3.4715 1.1341 3.1148 3.3452 2.9969 0.6242 2.5960 3.9745 2.0811 1.2933 0.1543 1.7560
% Find element of dleta_A that is closest to 3.1528.
differences = abs(dleta_A - 3.1528);
[minDifference, indexOfMin] = min(differences)
minDifference = 0.0022
indexOfMin = 871
closestValue = dleta_A(indexOfMin)
closestValue = 3.1550

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by