Save matrix from "writematrix" to clipboard

3 次查看(过去 30 天)
Hi, I need to save a matrix to the clipboard. Because the points need to be seperated by comma, I used the function "writematrix".
a = [1 2 4;5 6 7;8 9 10];
type Bachelorarbeit.txt
1,2,4 5,6,7 8,9,10
Now i need to save the matrix shown in Matlab to the clipboard. Is there a way to do so? I could not find anything.
Thanks for helping me.
  2 个评论
Tim Schaller
Tim Schaller 2023-2-18
Hi, I already tried it with clipboard. The problem is that I need to save it in the exact way it is shwon in the text file. But I don't know how to do that.



dpb 2023-2-18
You've got to create the entire text as a string or char() variable.
It would be more efficient to avoid the intermediary disk file...
a = [1 2 4;5 6 7;8 9 10];
fmt=[repmat('%g,',1,size(a,2)-1) '%g\n'];
content =
'1,2,4 5,6,7 8,9,10 '
  3 个评论
Tim Schaller
Tim Schaller 2023-2-19
I fugured it out by myself. You just need to change the mode of sprintf form g to f.
Thank you so much!


更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by