简体   繁体   English

将八度音程/matlab 输出写入剪贴板

[英]write octave/matlab output to clipboard

iam looking for a way to get the output of an octave statement to the windows clipboard.我正在寻找一种将八度音程语句的输出输出到 Windows 剪贴板的方法。

iam not searching a way to just manually copy/paste text from the cmd window (i know how this would work).我不是在寻找一种方法来从 cmd 窗口手动复制/粘贴文本(我知道这将如何工作)。 iam also not looking for getting the whole output of a complete octave session which could be gotten by launching octave with a script to execute and piping all output to some clip.exe.我也不希望获得完整的八度音程会话的整个输出,这可以通过使用脚本启动八度音程来执行并将所有输出管道传输到某些 clip.exe 来获得。
i want to capture the output from some single statement that will be executed from octave promt or some function or script.我想从某些单个语句中捕获输出,这些语句将从八度提示或某些函数或脚本中执行。

Would be great if someone has some advice.如果有人有一些建议,那就太好了。

Edit:编辑:
from a comment i learned about the clipboard command of matlab that is unfortunally not implemented yet in octave.从评论中我了解到 matlab 的剪贴板命令,不幸的是尚未在八度音阶中实现。
maybe any other ideas involving fancy system() calls?也许还有其他涉及花哨的system()调用的想法?

Well, apparently it's not too difficult to implement something fairly similar to Matlab - after a few minutes of fiddling around, behold my new clipboard.m : 那么,显然这不是难以实现非常相似Matlab的东西-摆弄周围的几分钟后,见我的新clipboard.m

function clipboard(data)
if ~ischar(data)
    data = mat2str(data);
end
data = regexprep(data, '\\','\\\\');
data = regexprep(data, '%','%%');
f = tempname;
h = fopen(f, 'w');
fprintf(h, data);
fclose(h);
system(['clip.exe < ' f]);
delete(f);
end

You could always call something like xclip through a system command. 您总是可以通过system命令调用xclip东西。 For examples of xclip usage, see here 有关xclip用法的示例,请参见此处

The following Matlab command works for putting multiline stuff into the clipboard on Mac. 以下Matlab命令可用于将多行内容放入Mac上的剪贴板。 Presumably you would substitute pbcopy with xclip and it would work on linux. 想必你会替代pbcopyxclip ,它将工作在Linux上。

>> system(['echo "line1' 10 'line2' 10 'line3" | pbcopy'])

如何将剪贴板中的内容移动到字符串变量中?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM