matlab读取剪贴板,Matlab剪贴板精度 - 格式长 -

我需要将几个矩阵从matlab复制到excel,所以我做了我的研究,我发现了一个名为num2clip的非常棒的脚本,它将所选的数组带到了剪贴板。

唯一的问题是数字格式很短,当我希望它很长时。

我怀疑"双"在脚本中使用的类型,但我仍然是matlab的新手,所以我确实有一些重要的缺点。

以下是我发现的脚本,为了保持长输入格式,我必须做些什么?

function arraystring = num2clip(array)

function arraystring = num2clip(array)

%NUM2CLIP copies a numerical-array to the clipboard

%

% ARRAYSTRING = NUM2CLIP(ARRAY)

%

% Copies the numerical array ARRAY to the clipboard as a tab-separated

% string. This format is suitable for direct pasting to Excel and other

% programs.

%

% The tab-separated result is returned as ARRAYSTRING. This

% functionality has been included for completeness.

%

%Author: Grigor Browning

%Last update: 02-Sept-2005

%convert the numerical array to a string array

%note that num2str pads the output array with space characters to account

%for differing numbers of digits in each index entry

arraystring = num2str(array);

%add a carrige return to the end of each row

arraystring(:,end+1) = char(10);

%reshape the array to a single line

%note that the reshape function reshape is column based so to reshape by

%rows one must use the inverse of the matrix

%reshape the array to a single line

arraystring = reshape(arraystring',1,prod(size(arraystring)));

%create a copy of arraystring shifted right by one space character

arraystringshift = [' ',arraystring];

%add a space to the end of arraystring to make it the same length as

%arraystringshift

arraystring = [arraystring,' '];

%now remove the additional space charaters - keeping a single space

%charater after each 'numerical' entry

arraystring = arraystring((double(arraystring)~=32 |...

double(arraystringshift)~=32) &...

~(double(arraystringshift==10) &...

double(arraystring)==32) );

%convert the space characters to tab characters

arraystring(double(arraystring)==32) = char(9);

format long e

%copy the result to the clipboard ready for pasting

clipboard('copy',arraystring);

祝你好运。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值