八度函数调用中未定义的arg(是的' sa脚本文件)
请回答
eulerballistic(motion, [0;100;0;-9.8;0], 10)
needs to be
eulerballistic(@motion, [0;100;0;-9.8;0], 10)
^
当我将这两个功能复制并粘贴到CLI中时, ,我会得到“错误:v Undefined” 当我发出“运行proj3b.m”时,同样的问题 我知道脚本文件和功能文件之间的区别。 当我正确地将proj3b.m放入函数文件时,我会遇到相同的错误。
使用八度6.4.0
proj3b.m
1+1;
function z = motion(t, v)
x2 = 0;
y2 = -9.8;
z = v + [v(3); v(4); x2; y2; 1]*t;
return
endfunction
eulerballistic(motion, [0;100;0;-9.8;0], 10)
eulerballistic.m
function z = eulerballistic(f, z0, deltat)
z = z0;
i = 1;
while z(2,i) > 0
zprime = f(z(5,i), z(:,i))
z(:,i+1) = z(:,i) + deltat*zprime;
i = i + 1;
if i > 100
break;
end
end
z = z(:, 1:end-1);
end
ANSWER
eulerballistic(motion, [0;100;0;-9.8;0], 10)
needs to be
eulerballistic(@motion, [0;100;0;-9.8;0], 10)
^
When I copy and paste these two functions into the cli, I get "error: v undefined"
When I issue "run proj3b.m", same problem
I know about the difference between a script file and a function file.
When I make proj3b.m into a function file properly, I get the same error.
Using octave 6.4.0
proj3b.m
1+1;
function z = motion(t, v)
x2 = 0;
y2 = -9.8;
z = v + [v(3); v(4); x2; y2; 1]*t;
return
endfunction
eulerballistic(motion, [0;100;0;-9.8;0], 10)
eulerballistic.m
function z = eulerballistic(f, z0, deltat)
z = z0;
i = 1;
while z(2,i) > 0
zprime = f(z(5,i), z(:,i))
z(:,i+1) = z(:,i) + deltat*zprime;
i = i + 1;
if i > 100
break;
end
end
z = z(:, 1:end-1);
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
呼叫仪需要在功能名称前的限制符 @。
The callsite needs the qualifier @ in front of the function name.