Undefined function or variable inside a for loop within a function

I write a function to compute the Kendall distance using a for-loop
function [ distance ] = kendall_tau(y, yy, pair_list)
distance = 0;
for row = 1:length(pair_list)
i = pairlist(row,1);
j = pairlist(row,2);
if (y(i)<y(j))&&(yy(i)>yy(j)) || (y(i)>y(j))&&(yy(i)<yy(j))
distance = distance + 1;
end
end
When I try this function with real values this undefined variable keep raising and I dont know why
kendall_tau(y_valid,y_valid_shuffle,pair_list_valid)
y_valid, y_valid_shuffle is 150x1 matrix, pair_list_valid is 978x2 matrix
Undefined function or variable 'pairlist'.
Error in kendall_tau (line 17)
i = pairlist(row,1);
I'm noob in matlab. Thank for oyur help

댓글 수: 1

You should work in the same directory/ folder where this function is stored. Are you doing it?

댓글을 달려면 로그인하십시오.

답변 (1개)

Stephen23
Stephen23 2017년 11월 9일
편집: Stephen23 2017년 11월 9일

1 개 추천

The input argument is named pair_list (with an underscore), but in the code you use pairlist (without underscore).

카테고리

도움말 센터 및 File Exchange에서 Embedded Coder에 대해 자세히 알아보기

질문:

2017년 11월 9일

편집:

2017년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by