handling arrays of strings
1 次查看(过去 30 天)
显示 更早的评论
I want to create an array of strings in a manner that allows the strings to be easily changed, I would like something like this:
Signals = cellstr('Signals');
horzcat(Signals,...
'SignalName1',...
'SignalName2',...
'SignalName3',...
'SignalName4',...
'SignalName5', );
The problem is that horzcat merges the strings, is there a simple way to achieve this? James
4 个评论
per isakson
2015-2-17
编辑:per isakson
2015-2-17
I often use this way to write cell arrays of strings in code. The string 'SignalName3' is commented out. It is easy to read and edit. Often I want a row to use in a for-loop:   for signal = Signals
Signals = {
'Signals'
'SignalName1'
'SignalName2'
... 'SignalName3'
'SignalName4'
'SignalName5'
};
Signals = transpose({
'Signals'
'SignalName1'
'SignalName2'
... 'SignalName3'
'SignalName4'
'SignalName5'
});
回答(1 个)
pankhuri kasliwal
2019-6-25
编辑:pankhuri kasliwal
2019-6-25
Signals= cellstr('Signals');
Signals = [Signals, 'SignalName1'];
Signals = [Signals, 'SignalName2'];
This way it won't merge the strings all together, you will get all the strings in an array.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!