the question is : in pushbutton callback i read this code:
C=[h1 h2 h3 h4 h5 h6];
set(handles.uitable1,'DATA',C);
the uitable1 display the result in the first row,
while i will change the value of C, when i push the pushbutton again, how to write C to sceond row?

 Respuesta aceptada

Walter Roberson
Walter Roberson el 11 de Dic. de 2017

1 voto

current_data = get(handles.uitable1, 'data');
newdata = [current_data; C];
set(handles.uitable1, 'data', newdata);

12 comentarios

ww ww
ww ww el 11 de Dic. de 2017
thank you ,I read this code ,but when i push the pusbutton ,the uitable show two row .
ww ww
ww ww el 11 de Dic. de 2017
i want when i fist push the button ,the uitable show the first row,when i second push,the uitable show the data in second row ,and so on ,the first row save the date which not changed.
Jan
Jan el 11 de Dic. de 2017
@ww ww: I do not really understand, what you are asking for. What should appear in the first and second row at the third click?
ww ww
ww ww el 11 de Dic. de 2017
such as,I have an edit1 ,an uitable1 and a pushbutton1,I write data to edit1,after some caculations,I get the data C and show in frist row of uitable, now,I will write different data to edit1,then I get the different data C,so,I want to show the different data C in sceond row of uitable1,if I change data C again,it will be show in third row.
ww ww
ww ww el 11 de Dic. de 2017
@Jan Simon: thank you very much,how can i do this?
Jan
Jan el 11 de Dic. de 2017
@ww ww: But this is exactly what Walter's suggestion does.
By the way, I asked: "What should appear in the first and second row at the third click?" As far as I understand, the answer is: "The values create by the first and second click".
ww ww
ww ww el 11 de Dic. de 2017
Editada: ww ww el 11 de Dic. de 2017
@Jan Simon but,it can not work,i took Walter Roberson advice,i mean,when i frist click,uitable show like this
this is my code
C=[h12 q3 pwf2 cy2 glr2 qd]; %one row
set(handles.uitable3,'DATA',C);
current_data = get(handles.uitable3, 'data');
newdata = [current_data; C];
set(handles.uitable3, 'data', newdata);
i mean,i have only one pushbutton,when i frist click,uitable show the first row,when i second click ,the data show in second row ,but,now when i second click, the data covered the first row.
Walter Roberson
Walter Roberson el 11 de Dic. de 2017
Remove the
set(handles.uitable3,'DATA',C);
ww ww
ww ww el 11 de Dic. de 2017
@Walher Roberson think you very much ,that is ok!
ww ww
ww ww el 12 de Dic. de 2017
@Walter Roberson: sorry,I try agian this code ,it is can not work again,if i remove:
set(handles.uitable3,'DATA',C); % code
how can i get data from uitable? this is error
ww ww
ww ww el 12 de Dic. de 2017
add an pushbutton~that is ok
Walter Roberson
Walter Roberson el 12 de Dic. de 2017
For this to work the first time, the data property has to have been left initialized to its default [] .
For it to continue to work, the number of columns in C needs to be the same as the number of columns in the existing table.
I suspect some of your calculated h values might be empty, giving you a C shorter than previous rows. Use the debugger to find out.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Preguntada:

el 11 de Dic. de 2017

Comentada:

el 12 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!