How to display in a table?

There are total 36 states with me in a table named "Mytable", each state being 6 characters long.
Suppose, I have an initial state (column cell), A=[i, j, k, l, m, n]; and final state (row cell), C=[i+1, j, k, l, m, n];
I want to show the output in "Mytable" as 'hello' whenever a transition like A to C types takes place.
What function, coding can be used to display 'hello' in "Mytable" in such kind of transitions?
Kindly suggest

2 comentarios

Image Analyst
Image Analyst el 9 de Oct. de 2017
Are A and C table variables, or cell arrays, or double arrays?
surabhi sachdeva
surabhi sachdeva el 10 de Oct. de 2017
A and C represent state transition rules. They are double arrays.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Oct. de 2017
Editada: Walter Roberson el 9 de Oct. de 2017

0 votos

states = {'000000', '100000', '012103', '112103', '212103', '230213'};
prefix = 't';
varnames = strcat({prefix}, states);
rownames = states;
MyTable = array2table(cell(6,6),'VariableNames', varnames, 'RowNames', rownames);
A = [0 1 2 1 0 3];
C = A + [1 0 0 0 0 0];
src = sprintf('%d', A);
dst = [prefix sprintf('%d', C)];
MyTable{src, dst} = {'hello'};
... However, last time we checked with you, you were using R2013a, which does not have table objects, so this would not seem to be of any interest to you ?

7 comentarios

surabhi sachdeva
surabhi sachdeva el 10 de Oct. de 2017
Yes, very right. It's not working in R2013a. Is there any other way out for this?
Kindly tell
Walter Roberson
Walter Roberson el 10 de Oct. de 2017
states = {'000000', '100000', '012103', '112103', '212103', '230213'};
prefix = 't';
varnames = strcat({prefix}, states);
rownames = states;
MyTable = mat2dataset(cell(6,6),'VarNames', varnames, 'ObsNames', rownames);
A = [0 1 2 1 0 3];
C = A + [1 0 0 0 0 0];
src = sprintf('%d', A);
dst = [prefix sprintf('%d', C)];
MyTable{src, dst} = {'hello'};
I have not tested the above as my computer is doing some heavy computation at the moment.
Walter Roberson
Walter Roberson el 10 de Oct. de 2017
Editada: Walter Roberson el 10 de Oct. de 2017
Yep, worked fine. Rather than waiting for me, you would have been able to deduce the appropriate adjustments by looking back to the posting where I showed you how to construct the 729 x 729 first as a table object, and then when I found out you had R2013a, I showed you the equivalent dataset code.
surabhi sachdeva
surabhi sachdeva el 10 de Oct. de 2017
But, sir,
from this code it is clear that it is only for these two particular values of A[012103] and C.
Whereas, what I want is something general by which there is an automated transition of states whenever a value of type A is encountered. A 36x36 matrix in which
column denoting a value of type A[i, j, k, l, m, n] and
row denoting a value of type C[i+1, j, k, l, m, n]
surabhi sachdeva
surabhi sachdeva el 10 de Oct. de 2017
Editada: Walter Roberson el 10 de Oct. de 2017
I am looking for an automated solution to the complete 36x36 matrix.
How can that is possible?
Walter Roberson
Walter Roberson el 10 de Oct. de 2017
You need to provide it with the source states at least. It is not possible to create a "macro" that automatically adds the target state and appropriate entry as soon as it detects that a new source state has been added.
states = {'000000', '100000', '012103', '112103', '212103', '230213'};
prefix = 't';
varnames = strcat({prefix}, states);
rownames = states;
MyTable = mat2dataset(cell(6,6),'VarNames', varnames, 'ObsNames', rownames);
A = [0 0 0 0 0 0; 0 1 2 1 0 3; 1 1 2 1 0 3 ];
C = bsxfun(@plus, A, [1 0 0 0 0 0]);
src = cellstr( num2str(A, '%d'));
dst = strcat( {prefix}, cellstr( num2str(C, '%d') ));
for K = 1 : length(src)
MyTable{src{K}, dst{K}} = 'hello';
end
In the above, you can create your "A" array by using the filter techniques we discussed in your earlier postings.
surabhi sachdeva
surabhi sachdeva el 11 de Oct. de 2017
OK, sir. It means I have to add all the input states individually.
Thanks so much for your immediate responses. I was confused about this before.
Now I will try according to your suggestions.
Thanks once again.
Regards Surabhi

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Oct. de 2017

Comentada:

el 11 de Oct. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by