App Designer Tab name xlsl

2 views (last 30 days)
Daniel
Daniel on 23 Sep 2022
Commented: Daniel on 24 Sep 2022
Hi, im new, I never used matlab and the app designer, but I need to do a project and for now I only need to know how to assign the name of a tab to the name of a cell of the selected excel.
I know how to read xlsl files, but I tried all the day to do that and I can't. The file cells are something like: "%%Motor speed" (I dont have right now the excel to share a image but there are like this) and they have the "%" and I know in matlab % is for comments so probably theres something that I dont know and the "%" are for something.
Matlab sometimes says "Warning: Variable names were modified to make them valid MATLAB identifiers. The original names are saved in the VariableDescriptions property." Here are some examples of what I need to do:
I know this is probably a stupid question for someone who knows how this works, but I dont really have that much time.

Accepted Answer

Turlough Hughes
Turlough Hughes on 24 Sep 2022
Have a look at your component browser in the app designer, and you'll see app.Tab1 or something similar (as shown above).
Click on app.Tab1 and you will get a list of the Tab's properties - one of those properties is Title. You can modify this property in code-view by:
app.Tab1.Title = strrep(theValueFromExcel,'%',''); % I just use strrep to remove the '%' symbol.
I recommend making a Startup function to set that property, which runs automatically when you open the app. So, you can place that line of code inside the StartupFcn to set the tab name when the app is instantiated. Just make sure that theValueFromExcel is available before your call the the above code snippet.
To create a StartupFcn, navigate to the component browser, right click the top of the tree (i.e. app1 or whatever your app is called) and go to >> CallBacks >> Add StartupFcn callback.
Regarding your concern on the '%' symbol, if you load that into a variable (e.g. theValueFromExcel, in the above code snippet) it will not cause any code to be skipped.
If you can manage this, I would say you're doing quite well for someone who's never used Matlab before.
  1 Comment
Daniel
Daniel on 24 Sep 2022
It worked perfect, thanks you.

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by