【发布时间】:2015-11-15 06:22:46
【问题描述】:
我正在使用以下代码:
for t = linspace(0,2,500)
x(t) = 1+ t^2;
y(t) = 2*t;
r(t) = sqrt((x(t))^2+(y(t))^2);
radius = 1.6
if r(t) > 0.999*radius & r(t) < 1.001*radius then
solucion = t;
end
end;
disp(solucion, "the solution is:")
这适用于t > 1 和不同的半径值。
但是当 t 取 0 到 1 之间的值时,我得到 error 21: Invalid index。
我也需要处理这些价值观。我该如何处理?
【问题讨论】:
-
如果它像 MATLAB 一样工作,你只能用正整数索引东西。使用一个数组(例如
0:0.01:1)并使用您的循环变量访问它,它是整数