필터 지우기
필터 지우기

3d table interpolation

조회 수: 1 (최근 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 CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by