matlab中命令行输入,命令行Matlab中的vi输入模式?

Brooks Moses..

5

是的,这应该很容易.这只是一般情况下"打开一个进程并绑定其stdin和stdout"问题的一个特例,这并不困难.

更新:看起来你的包装几乎就在那里.你需要完成的是识别Matlab何时要求输入,然后只询问用户输入.我建议尝试这个伪代码:

while input_line = Readline.readline('>> ', true)

io.puts input_line

while ((output_line = io.gets) != '>> ') // Loop until we get a prompt.

puts io.gets

end

end

这不太对,因为在你要求第一个输入行之前你需要做一次内循环,但它应该给你一个想法.您可能还需要调整它正在查找的提示文本.

更新2:好的,所以我们还需要考虑提示后没有EOL的事实,因此io.gets将挂起.这是一个修订版本,它使用了一个事实,你可以给Matlab提示一个空行,它只会给你另一个提示而不做任何事情.我重新安排了循环以使事情变得更清晰,但这意味着你现在必须添加逻辑来弄清楚你什么时候完成.

while [not done] // figure this out somehow

io.puts blank_line // This will answer the first

// prompt we get.

while ((output_line = io.gets) != '>> ') // Loop until we get a prompt.

puts io.gets // This won't hang, since the

end // prompt will get the blank

// line we just sent.

input_line = Readline.readline('>> ', true) // Get something, feed it

io.puts input_line // to the next prompt.

output_line = io.gets // This will eat the prompt that corresponds to

// the line we just fed in.

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值