Functions in app designer

조회 수: 8 (최근 30일)
Sam Horigan
Sam Horigan 2021년 5월 7일
답변: Cris LaPierre 2021년 5월 7일
Wondering how to put a function full of switch cases into the app designer so that when a varible is selected in the 'edit feild (numeric)' it does the set equation.
currently this is my function:
function y = UnitConversionsFunction(x, options)
%unit conversions
switch options
case 'c2f'%cel to fah
y=(x*9/5)+32;
case 'f2c'%fah to cel
y=(x-32)*5/9;
case 'mil2fo'%milliltres to fluid ounce
y= x/29.5735;
case 'fo2mil'%fluid ounce to millilitres
y= x*29.5735;
case 'l2p'%litre to pints
y= x*1.75975;
case 'p2l'%pints to litres
y= x/1.75975;
case 'l2g'%litres to gallons
y=x/4.54609;
case 'g2l'%gallons to litres
y= x*4.54609;
case 'kilj2kilc' %kiloj to kiloc
y=x/4.184;
case 'kilc2kilj'%kiloc to kiloj
y= 4.184*x;
case 'pas2psi' %pas to psi
y= x/6894.76;
case 'psi2pas' %psi to pas
y= x*6894.76;
otherwise
error ('please enter correct option')
end
end

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 5월 7일
This page shows how to add a custom function to an app. Note that the first input is the app structure.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by