write octave/matlab output to clipboard

iam looking for a way to get the output of an octave statement to the windows clipboard.

iam not searching a way to just manually copy/paste text from the cmd window (i know how this would work). 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. 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. maybe any other ideas involving fancy system() calls?

Answers


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:

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. For examples of xclip usage, see here

The following Matlab command works for putting multiline stuff into the clipboard on Mac. Presumably you would substitute pbcopy with xclip and it would work on linux.

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

Need Your Help

uncaught throw :warden in Devise Testing

ruby-on-rails testing rspec devise warden

I have just begun with testing Devise. I am unable to understand of why i am getting this error ::

Mapcache not caching WMS

nginx wms mapserver bitmapcache

I have mapcache, mapserver(WMS), nginx on ubuntu. My instruction: