フィルターのクリア

3d table interpolation

3 ビュー (過去 30 日間)
Mustafa Duran
Mustafa Duran 2024 年 3 月 23 日
編集済み: Matt J 2024 年 3 月 23 日
function T = bul(f, h)
% Verilen x, y ve z değerleri
T_values = [5, 6,7];
f_values = [10, 20];
h_values = [1, 2; 3, 4;5 6];
% Verilen y değerine en yakın y değerini bul
[~, f_index] = min(abs(f - f_values));
% Y değeri için interpolasyon yap
T_interp = interp1(f_values, T_values, f, 'linear');
% Z matrisindeki ilgili sütundaki interpolasyon yap
h_column = h_values(:, f_index);
T = interp1(h_column, T_values, h, 'linear');
end
that is my code, i want it like this:
f 10 20
T
5 1 2
6 3 4
7 5 6
i want an interpolation like f values will be assigned to closest f value in f_values and later, with h values that entered there must be interpolation to find corresponding T value. For example it must find T= 5.5 if call bul(10,2). But MATLAB gave me error with that writing, the error was:
Error using interp1>reshapeAndSortXandV
X and V must be of the same length.
Error in interp1 (line 128)
[X,V,orig_size_v] = reshapeAndSortXandV(X,V);
Error in bul (line 11)
T_interp = interp1(f_values, T_values, f, 'linear');
Error in untitled13 (line 1)
bul(10,2)
how can i fix that?
  1 件のコメント
Manikanta Aditya
Manikanta Aditya 2024 年 3 月 23 日
The error message you’re seeing is due to the mismatch in the lengths of f_values and T_values in the interp1 function. The interp1 function requires that the vectors X and V be of the same length. In your case, f_values and T_values are serving as X and V.
function T = bul(f, h)
% Verilen x, y ve z değerleri
T_values = [5, 6, 7];
f_values = [10, 20];
h_values = [1, 2; 3, 4; 5, 6];
% Verilen y değerine en yakın y değerini bul
[~, f_index] = min(abs(f - f_values));
% Y değeri için interpolasyon yap
T_interp = interp1(f_values, T_values(f_index), f, 'linear');
% Z matrisindeki ilgili sütundaki interpolasyon yap
h_column = h_values(:, f_index);
T = interp1(h_column, T_values, h, 'linear');
end

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by