0

I'm using App Designer in MATLAB. I have created a push button, 51-54 work no problem, then when I assigned another function into it (highlighted in the screenshot), it wouldn't work!

Please help me overcome this problem.

Screenshot showing the problem:

Screenshot showing the problem

Sardar Usama
  • 19,536
  • 9
  • 36
  • 58

1 Answers1

0

Problem: function inside of a function the way it is written in the screenshot. 4 things come up my mind:

  1. Generally:

yourApp.mlapp or any other code.m file

function  someProcess()
end

function subProcess()
end

  1. In your case rather try to write your function in an second .m file and call it from within your your app. be sure to have it on the MATLAB path.

yourApp.mlapp or any other code.m file

function someProcess()    
   subProcess();
end

+ external code.m file

function someProcess()    
   subProcess();
end
  1. define your function as a public or private function (method) inside the app. ( for others: the block is not there by default. click: app designer> code view > function > add private function | add public function)

screenshot

  1. if your function is only used once you could also write an anonymous function

https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html

erkandem
  • 136
  • 1
  • 7