Creating Variable from app.dropdowmenu.value

Hi, please i need help in creating a variable from user selection in drop down menu.
Example
%I tried this but not working
app.SelectInputDataDropDown.Value = %some equation

답변 (1개)

Image Analyst
Image Analyst 2021년 6월 22일
편집: Image Analyst 2021년 6월 22일

0 개 추천

It's the other way around. The app.SelectInputDataDropDown.Value expression is the user's selection, so to assign that to some variable you want, you have to put it on the right hand side of the equation, like
temperatureInCelsius = app.SelectInputDataDropDown.Value;
temperatureInFahrenheit = (9/5) * temperatureInCelsius + 32;
or perhaps if you want the contents of the list rather than it's index, you can do
allItems = app.SelectInputDataDropDown.String;
selectedIndex = app.SelectInputDataDropDown.Value;
temperatureInCelsius = str2double(allItems{selectedIndex});
temperatureInFahrenheit = (9/5) * temperatureInCelsius + 32;

댓글 수: 5

In my case will this work ? this is what am thinking off
sim('Phase_2_Diesel_Engine_Final_2020b', 'ReturnWorkspaceOutputs', 'on', 'SaveFormat', 'mat') = app.SelectInputDataDropDown.Value;
Actually this is my main challenge
I want to save to file the simout
The below code works.
DataSelected = app.SelectInputDataDropDown.Value;
simout = sim('Phase_2_Diesel_Engine_Final_2020b', 'ReturnWorkspaceOutputs', 'on', 'SaveFormat', 'mat')
save(DataSelected,simout);
What i really want is to save the simout as the dataselected.
I don't know what the sim() function is, but I doubt that would work. sim() looks like a function call where you're passing it lots of parameters. If so, you can't do that. For example, plot is a function and you can't set it equal to a control's value or anything else, so you cannot do
plot(x, y) = 42; % Not valid.
I suspect your line of code is similar.
The sim() function is used to run a simulink model. I am trying to assign the simulate output to the selected dropdown value
I don't have Simulink so I can't help you, but good luck with it.

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2021년 6월 22일

댓글:

2021년 6월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by