创建一个字符串数组 [英] Create an array of strings

查看:76
本文介绍了创建一个字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在for循环中的MATLAB中创建字符串数组?

Is it possibe to create an array of strings in MATLAB within a for loop?

例如,

for i=1:10
Names(i)='Sample Text';
end

我似乎无法以这种方式做到这一点.

I don't seem to be able to do it this way.

推荐答案

您需要使用单元格数组:

You need to use cell-arrays:

names = cell(10,1);
for i=1:10
    names{i} = ['Sample Text ' num2str(i)];
end

这篇关于创建一个字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆