Borrar filtros
Borrar filtros

Table consist of strings and numerics

3 visualizaciones (últimos 30 días)
Ernest Modise - Kgamane
Ernest Modise - Kgamane el 24 de Mzo. de 2021
Respondida: Ramnarayan Krishnamurthy el 24 de Mzo. de 2021
Hello, I saw this response to the above question
>>A = {'a','b'}';
>> B = {1,3}';
>> T = table(A,B);
>> disp(T)
A B
_____ _____
{'a'} {[1]}
{'b'} {[3]}
>> T.A{1}
ans =
'a'
I wanted to use the same approach to create a table like / or any other suitable approach
0 00
1 01
2 11
3 101
4 1001
5 10001
6 100001
where 0 - 6 are the table index in numerics, and 00 to 100001 are some binary code I want to be a string.
Now using your code above if I print T.A{1}
My results come with quotes, ' '
For my application I want for example to output to be a concatenated string say for index 3 (101) and index 1 (01) in that order,
i.e. 10101
for the example above, the code below will output '101''01'
Please help on how I can resolve this.

Respuesta aceptada

Ramnarayan Krishnamurthy
Ramnarayan Krishnamurthy el 24 de Mzo. de 2021
Once you setup the table, you can use sprintf to create the concatenated string. You would have to decide how will passing the index values.
Here is some example code:
% Setup the values for the table
% Indices
A = {0,1,2,3,4,5,6}';
% Binary values for the second column
B = {"00","01","11","101","1001","10001","100001"}';
% Create the Table
T = table(A,B);
% Print the concatenated string with the respective indices
sprintf('%s"%s',T.B{4},T.B{2})
HTH

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by