App Designer Tab name xlsl

조회 수: 8 (최근 30일)
Daniel
Daniel 2022년 9월 23일
댓글: Daniel 2022년 9월 24일
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.

채택된 답변

Turlough Hughes
Turlough Hughes 2022년 9월 24일
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
Daniel
Daniel 2022년 9월 24일
It worked perfect, thanks you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by