开发者

how to handle array of string?

开发者 https://www.devze.com 2023-04-13 08:38 出处:网络
Inside a Matlab function I need something like (as you can imagine in real life it should be represented as a fo开发者_如何学Gor loop):

Inside a Matlab function I need something like (as you can imagine in real life it should be represented as a fo开发者_如何学Gor loop):

var(1) = 'First string';
var(2) = 'Second string';
...
var(i) = 'i-th string';

Alas, I can't do this cause var(1) should contain just a character (not an entire string) and I get:

??? Subscripted assignment dimension mismatch.

I've searching on the web, but I can't find a good solution, any ideas?


Use a Matlab cell array:

var{1} = 'first string';
var{2} = 'second string';
var{n} = 'nth string';
0

精彩评论

暂无评论...
验证码 换一张
取 消