MATLAB Answers

Brian
0

GUIDE and selecting functions to apply on data

Asked by Brian
on 16 Mar 2013

I need to make a GUI in which different functions can be selected from a pop-down menu to work with data already loaded into the workspace. I just need to know the syntax in the m file for the gui:

if (function name) in list is selected

use this function

Apologies, this is a basic question, I have tried looking it up for a while and couldn't find anything. Thanks

  0 Comments

Products

No products are associated with this question.

2 Answers

Answer by Azzi Abdelmalek
on 16 Mar 2013
 Accepted answer

You can use str2func function

  1 Comment

Brian
on 18 Apr 2013

Thanks for the reply, sorry for the delay, I thought an email would be sent when it was answered. How do I put this code under the Callback(hObject... or CreateFcn(hobject... ? thanks


Answer by Jan Simon
on 16 Mar 2013
List     = {'sin', 'cos', 'tan'};  % String of the listbox
Value    = 2;                      % Value property of the listbox
Selected = List{Value};
Data     = 1.1415;                 % "data already loaded into the workspace"
result   = feval(Selected, Data)

  3 Comments

Brian
on 18 Apr 2013

Thanks for the reply, sorry for the delay, I thought an email would be sent when it was answered. How do I put this code under the Callback(hObject... or CreateFcn(hobject... ? thanks

Jan Simon
on 18 Apr 2013

I guess you want it in the callback. Simply try it.

Brian
on 18 Apr 2013

I'm really lost, sorry. Thanks very much, I'll work away on that


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!