from MATLAB command line , when I type my variable a , it gives me values as expected :
a =
value_1
value_2
and I would like to access to each value of a, I tried a(1) but this gives me empty
the type of a is 1x49char.
how could I get value_1 and value_2 ?
whos('a')
Name Size Bytes Class Attributes
a 1x49 98 char
I get the a from xml file :
<flag ="value">
<flow>toto</flow>
<flow>titi</flow>
</flag>
a+0:
ans =
10 32 32 32 32 32 32 32 32 32 32 32 32 98,...
111 111 108 101 97 110 95 84 10 32 32 32 32 32,...
32 32 32 32 32 32 32 66 79 79 76 10 32 32,...
32 32 32 32 32 32 32
You seem to have an somewhat inconvenient character array. You can convert this array in a more manageable form by doing something like what @Richante said:
Then you can reference to
totoandtitibyNote that
strings{1}is empty, sinceastarts with a newline character. Note also that you don’t need astrtrim— that is taken care of bystrreadalready. You can circumvent the initial newlines by doingbut I’d only do that if the first newline is consistently there for all cases. I’d much rather do
Finally, if you’d rather use
textscaninstead ofstrread, you need to do 1 extra step: