Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to convert a script with call backs to uitable into function

2 visualizaciones (últimos 30 días)
Sanjeev Kumar
Sanjeev Kumar el 6 de Sept. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have a script with two callbacks to two uitables, how can I convert this into a function

Respuestas (1)

Robert U
Robert U el 7 de Sept. de 2017
Hi Snjeev Kumar,
from the information you provided the easiest way to create a function would be
function myFunctionName(~)
<- insert your script here ->
end
Kind regards,
Robert
  2 comentarios
Sanjeev Kumar
Sanjeev Kumar el 7 de Sept. de 2017
Hi Thanks Robert..
I am getting the following error after making my script a function
Struct contents reference from a non-struct array object.
Error in button_callback_2 (line 16)
out=cellfun(@str2num,myData.toArray.cell,'un',0)';
Error while evaluating UIControl Callback.
without making my script as function. its working without an error
Robert U
Robert U el 7 de Sept. de 2017
While using functions variables have to be placed in the function workspace. Variables that have been used in main workspace are not available unless they are defined as global (should be omitted).
If you need variables from outside function workspace you have to pass them. See https://de.mathworks.com/help/matlab/programming-and-data-types.html
And as I wrote: "from the information you provided..."

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by