我制作了一个Matlab程序,用于检测2个圆形是否相互交叉并输出交点的坐标。现在,我试图将代码转换为vhdl来实现FPGA。
我的代码中HDL Workflow Advisor中仍然存在错误的函数之一是:
function theta = angle2Points(p1,p2)
%ANGLE2POINTS Compute horizontal angle between 2 points
%
% ALPHA = angle2Points(P1, P2),
% Pi are either [1*2] arrays, or [N*2] arrays, in this case ALPHA is a
% [N*1] array. The angle computed is the horizontal angle of the line
% (P1 P2)
% Result is always given in radians, between 0 and 2*pi.
%
% See Also:
% points2d, angles2d, angle3points, normalizeAngle, vectorAngle
%
%
% ---------
dp = zeros(1,2);
% angle of line (P2 P1), between 0 and 2*pi.
dp = p2 - (size(p2, 1) * p1)
theta = mod(atan2(dp(:,2), dp(:,1)) + 2*pi, 2*pi)错误:
变量'p1'。变量大小的数据不受支持。
变量'p2'。变量大小的数据不受支持。
变量'theta'。变量大小的数据不受支持。
用一个小测试文件来模拟传入的数据:
% P = [x,y]
P1 = [0,3];
P2 = [5,10];
f=angle2Points(P1,P2);
P1 = [0,3];
P2 = [5,3];
f2=angle2Points(P1,P2在Workflow Advisor中,我收到:不支持Variable-Size数据 - 第1行出错。
我明白这是因为像C这样的静态类型语言必须能够在编译时确定变量属性,而在Matlab中它是动态发生的。
我想就如何正确地重写代码以使其准备好hdl这个简单的功能提供一些帮助。
提前致谢