I have 2 strings type datas. One of them (txt) comes from [FileName,PathName] = uigetfile('*.xlsx','Select the excel file'), [num,txt1,raw] = xlsread(FileName), other is string data as matrix form. ı cannot put spaces between these strings.
2 次查看(过去 30 天)
显示 更早的评论
for example,
[FileName,PathName] = uigetfile('*.xlsx','Select the excel file')
[num,txt,raw] = xlsread(FileName) %one excel file selected...
txt={p.1;p.2;p.3} % cell
string_txt=char(txt) % in order to convert string data
a=[1;2;3] % string
data=[txt, a] %
I wanna combine "txt" and "a" as 3x2 matrix and assign these matrix into listbox. When I create [txt, a] I cannot seperate columns to each other, they looks united without spaces. How can I seperate the columns to each other and assign this data into listbox?
thanks in advance.
0 个评论
采纳的回答
Image Analyst
2013-5-27
Like I said in your duplicate post:
result=[howdy(2,:), ' ', names(3,:)];
or use sprintf(), like I prefer:
result = sprintf('%s %s', howdy(2,:), names(3,:));
By the way, if any names are not exactly the same length as the others, then you'll have to have names be a cell array, not a character array and you'll have to use braces, not parentheses, like I did here.
0 个评论
更多回答(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!