MATLAB Answers

cell array concatenation problem

1 view (last 30 days)
Leor Greenberger
Leor Greenberger on 13 May 2013
Hi
I am not sure what I am doing wrong. I have the following code.
BWL = [200 350 500 1000]*1E6;
filename = cell(4,2);
filename(:,1) = cellstr(strcat({'Sub Bandwidth '}, num2str(BWL'/1E6,'%-d')));
filename(:,2) = strcat(filename(:,1),' D1M ');
filename(:,1) = strcat(filename(:,1),' D50 ');
This gives me the following output.
filename =
'Sub Bandwidth 200 D50' 'Sub Bandwidth 200 D1M'
'Sub Bandwidth 350 D50' 'Sub Bandwidth 350 D1M'
'Sub Bandwidth 500 D50' 'Sub Bandwidth 500 D1M'
'Sub Bandwidth 1000 D50' 'Sub Bandwidth 1000 D1M'
This is what I want. Now when I add the following line of code.
filename = strcat(filename,{' MHz VISA _9500.mc'});
filename =
[1x39 char] [1x39 char]
[1x39 char] [1x39 char]
[1x39 char] [1x39 char]
[1x40 char] [1x40 char]
I don't understand why I end up with a cell array of chars instead of strings? Every line up until this point used strcat and output a cell array of strings. Can anyone help me understand what is happening and whether what I have here is the best way/fewest lines of code to get what I want? Thanks!

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 13 May 2013
Edited: Azzi Abdelmalek on 13 May 2013
What is the problem? your screen is too small to display the whole string
  1 Comment
Leor Greenberger
Leor Greenberger on 13 May 2013
Yes, I just realized that there is no problem. I thought that I had a cell array of char arrays when I want a cell array of strings.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!