0

I have a uitable that I set manually initial values and I have two buttons, so when a user pushes a button, the buttons call a function that I have created and do some values and I want to send that values to the uitable inside of main.m and update the uitable.

My question is how can I send values from external function to the uitable inside of main.m?

dsolimano
  • 8,870
  • 3
  • 48
  • 63
user3312370
  • 45
  • 1
  • 8
  • Correct me if I'm wrong, but you need 2 things right? 1) Get values from external function into `main.m` 2) Update the values in the table. Is that it? – Benoit_11 May 05 '15 at 20:06
  • the function that is called by function is done. So I want to send that values to uitable that is inside of main.m. The thing would be easy if the functon is inside of main.m I supposed, but I created a function outside of main.m. So the values of table will be updated continuously when the user push the button until the end of program – user3312370 May 05 '15 at 20:11
  • Have you looked at [setappdata](http://www.mathworks.com/help/matlab/ref/setappdata.html) and `getappdata`? That would be a perfect fit for your application – Benoit_11 May 05 '15 at 20:15
  • But that only work with gui in the same file.m, but I want to semd values from function outside of file.m – user3312370 May 05 '15 at 20:28
  • Nope that works in that case too. Use 0 to signify the base workspace. Eg: `setappdata(0,'VariableName',Variable)` and that should work fine – Benoit_11 May 05 '15 at 20:31
  • Excelend, put your awnser in the anwser section and I give you correct anwser – user3312370 May 05 '15 at 20:51
  • I have the last question, if I want when the user push button, the uitable update continusly, what can I do to do that? a for loop inside the button? – user3312370 May 05 '15 at 20:54
  • the `uitable` is a pain in the back to update programmatically (at least until my version of Matlab 2013a). You have to retrieve the full table content in a cell array, update the part you want, then resend the cell array to the `uitable`. No way to update just one element individually. – Hoki May 05 '15 at 21:28
  • I unserstand that. I explain my idea better. My table 4 rows, when the user push button, a function is called and the function send values to change all values of table but my question is, is there a way when the user push button , the values of all table will update constinuosly? I do not if I put a for loop around function inside push button or is there another way? – user3312370 May 05 '15 at 21:44
  • to update _continuously_ in the sense of _at regular (short) time interval_ you would need a `timer` object. If you mean _continuously_ in the sense of _every time the underlying data are changed_, then it's up to you to call an `update_table` function of yours at the end of the calculations which changed the values. There is no "automatic link" that you can do between the `uitable` `data` and some variable in a workspace. – Hoki May 05 '15 at 21:54
  • Yes, the thing is I have to do that 1000 time so in each iteraction I will have new values, for that reason I have and idea, is it possible or correct to put for loop around function that calculate new values inside push button ? – user3312370 May 05 '15 at 23:06

0 Answers0