I am on an older version of MATLAB (R2014A), and trying to output text that is stored in character vectors that are stored in a cell array.
I noticed that when I enter the character arrays manually there is no issue:
myStrings = repmat({''}, 1, 10);
for i = 1:10
myStrings{i} = 'This character array is quite lengthy but still prints to screen normally.';
end
myStrings'
Output: Column vector with the above sentence in every cell. (I want this)
But when I do something similar MATLAB outputs the size of each character array instead of the contents. [SomeStructure.SomeData is a cell vector where each cell is a character vector]
myStrings2 = repmat({''},1,10);
for i = 1:10
myStrings2{i} = SomeStructure.SomeData{i};
end
myStrings2'
Output: A column vector with entries simply listing the size of the char array (i.e [1x25 char]). (I get this)
When I view this SomeStructure.SomeData in my workspace, I see the strings I want, but when I call it in the console it also outputs these sizes. How do I get these strings/character vectors to behave the way I want? i.e, like the first block of code?
Other maybe helpful notes:
- When I call SomeStructure.SomeData, to the console one of the entries is a regular string and not the size of the string (last entry).
- I get the data structure by reading from input files using:
function [PS_Data] = getPSData(N,directory)
oldfolder = pwd;
cd(directory);
files = dir('*.txt');
for k = 1:length(files)
file = files(k).name;
fid = fopen([pwd '\' file]);
my_field = strtok(files(k).name,'.');
for i = 1:N
PS_Data.(my_field){i} = fgets(fid);
end
fclose(fid);
end