字符串存入xls matlab,使用Matlab将字符串写入excel?(Writing strings into excel using Matlab?)...

本示例展示了如何在Matlab中将包含字符串的单元格数组转换为单行字符串,并写入Excel文件。首先使用cellfun和strcat将每个单元格内的字符串连接,然后使用deblank去除尾部换行符。最后,使用xlswrite函数将处理后的数据写入Excel的指定单元格。
摘要由CSDN通过智能技术生成

UPDATED ANSWER:

If I understand correctly, it appears that your variable data is a cell array where each cell contains a 1-by-N (or perhaps N-by-1) cell array of strings. If you want to try and fit each of these cell arrays of strings into one cell of a spreadsheet, you are going to need to format each into a single long string first.

Here's an example of how you could format the cell arrays of strings by concatenating them together with a newline between them:

data = { {'hello' 'hi' 'hey'} ... %# Sample cell array of 1-by-N

{'world' 'earth' 'everyone'} ... %# cell arrays of strings

{'blah' 'blah'}};

data = cellfun(@(x) {strcat(x,{char(10)})},data); %# Add newline characters

%# to the string ends

data = cellfun(@(x) {deblank([x{:}])},data); %# Concatenate the inner cells and

%#

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值