필터 지우기
필터 지우기

interp1 function error

조회 수: 2 (최근 30일)
fima v
fima v 2020년 5월 7일
답변: Ameer Hamza 2020년 5월 8일
Hello i have made an interpolation of a descrete CSV file which is attached and turned it into continues function using interp1.
it went without an error , but when i tried to plot continues function using xq vector,it said
'Subscript indices must either be real positive integers or logicals.'
Where did i go wrong?
Thanks.
data = load('t2.csv');
x = data(:,1);
y = data(:,2);
%plot(x,y);
%hold on
x_data=x/(1e+6);
y_data=abs(y/(100));
plot(x_data,y_data);
coef_fun = @(lambda) interp1(x_data, y_data(x_data),lambda, 'linear', 'extrap'); %%%%FIRST FUNCTION
xq = linspace(5e-6,13.5e-6,10000);
plot(xq, coef_fun(xq))
%hold off

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 8일
No need to index y_data with x_data
coef_fun = @(lambda) interp1(x_data, y_data, lambda, 'linear', 'extrap'); %%%%FIRST FUNCTION

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by