MATLAB Answers

Accessing information within a structure in app designer and How to pass data from one push-button to the other

1 view (last 30 days)
Curious Mind
Curious Mind on 18 Jul 2020
Commented: Curious Mind on 20 Jul 2020
Hi, I am developing a simple app using the app designer. This is pretty new to me and I am not experienced when it comes to app designer or gui in general. I have the code below,
for i = numel(F(2))
U_R = [F.y]';
  1. Now F is a structure. It has 3 columns. Column 2 is labeled y and I want to assign y to U_R using U_R = [F.y]. When I run the gui I get an error '' Undefined fuction F for input arguments of type double'. How do I fix this problem?
  2. Also how do I add a property section such that I can access or pass data to every pushbutton in the gui (app)?
Thank you!


Show 1 older comment
Curious Mind
Curious Mind on 18 Jul 2020
1. Thanks for your response. F is a structure which is an output in workspace. How should I write the code for it to be recognized as a structure?
2. How do I add F which is a structure in the property section?
Rachel Surridge
Rachel Surridge on 18 Jul 2020
2. If F is in your base MATLAB workspace, you can import it into your app using a statement like this in the properties section of the app:
properties (Access = private)
F = evalin('base', 'F');
If the for loop you posted originally is inside the app, then I think the code above should resolve your first question too. F is likely not being recognized as a structure because the app doesn't know where to find it. Using the evalin statement will put F in a workspace that the app can access, so it will be able to recognize it as a structure.
Curious Mind
Curious Mind on 20 Jul 2020
Hi Rachel, thanks for the code. F is not being displayed in the workspace. When I run the code on the matlab command line and F appears in the workspace and then I run the app using your code the it works. Is there a way I can pass information/output from the app to the workspace? As long as F appears in the workspace then your code will work because the app will recognize it. Thanks!

Sign in to comment.

Answers (1)

Cris LaPierre
Cris LaPierre on 18 Jul 2020
In the upper left of app designer, you will have the ability to create properties. Use this to add a property to the app structure. This is what makes it available to all functions inside your app. See this page for speciic details.


Sign in to comment.




Community Treasure Hunt

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

Start Hunting!