【发布时间】:2017-02-03 13:08:41
【问题描述】:
我有这个函数,它接受图像的行/列坐标并返回相邻像素变化的方向。
function [d] = p_directions(row, col, img)
if img(row, col+1) == 2
if img(row, col) == 3
d = 'A+';
elseif img(row, col) == 1
d = 'B+';
elseif img(row, col) == 2
d = NaN;
end
end
if img(row, col) == 2
if img(row, col+1) == 3
d = 'A-';
elseif img(row, col+1) == 1
d = 'B-';
end
end
end
函数调用:
[row, col] = find_row_col(A);
[d] = p_directions(row, col, img)
错误信息:
Error in p_directions (line 15)
if img(row, col + 1) == 2
Output argument "d" (and maybe others) not assigned during call to "p_directions".
我想相信错误来自我脚本的第一行(“第 15 行”),在这种情况下,甚至不会计算变量“d”。我是编程新手,我不知道函数脚本的第一行到底有什么问题?请对此有任何帮助,建议或意见?提前谢谢你。
【问题讨论】: