How to Call a Function inside of a function

7 ビュー (過去 30 日間)
Bridget
Bridget 2023 年 4 月 30 日
回答済み: Walter Roberson 2023 年 4 月 30 日
Hi,
I am trying to design a app where the user will input a flowrate and length so the app can calculate the experimental and predicted pressure drop in any of 5 pipes.
I am using a 'switch' function to go through the user's selection of pipe# and however for pipe 4, the values are not calculated they are extracted from an array. I tried to use switch to go through the user's flowrate selection but do i have to input a function prior to this? If this is the case how do I input a function in a function? See below:
% Button pushed function: CalculateButton
function CalculateButtonPushed(app, event)
switch app.PipeDropDown.Value
case '1'
app.PredicteddPEditField.Visible = 'on';
app.PredicteddPEditFieldLabel.Visible = 'on';
app.ExperimentaldPEditField.Visible = 'on';
app.ExperimentaldPEditFieldLabel.Visible = 'on';
'more code here'
case '4'
Exp_dP = {44.58, 91.83, 871.01, 1298.94, 1339.94, 1251.39, 1198.19; 57.21, 124.22, 1119.59, 1616.46, 1534.74, 1551.09, 1493.88; 74.53, 183.87, 1716.98, 2545.96, 2337.25, 2329.90, 2371.43; 81.96, 224.15, 2273.51, 3358.78, 2846.03, 2869.85, 2986.83; 118.77, 312.59, 2901.88, 4273.92, 3682.84, 3744.36, 3913.74; 132.39, 354.67, 3755.95, 5594.69, 4137.18, 4254.86, 4445.09; 194.91, 476.17, 4679.95, 6956.18, 5187.72, 5224.49, 5586.11; 236.99, 580.23, 5769.58, 8551.40, 6222.32, 6397.20, 6818.89};
switch app.FlowrateDropDown.value
case '0.4'
Q = app.FlowrateDropDown.Value*(1/3600);
d = 0.026;
p = 1000;
u = 0.000001;
k = 0.03/1000; 'm';
v = (Q/((3.14)*((d/2)^2)))*(1/3600); 'm/s';
Re = (d*v*p)/u;
F = (3.6*log(6.9/Re)+((k/(3.7*d))^1.11))^-2;
L = app.LegnthDropDown.Value;
if L == 0.7
dP1 = 2*F*(L/d)*(v^2)*p;
app.PredicteddPEditField.Value = dP1;
dP2 = Exp_dP(1,1);
app.ExperimentaldPEditField.Value = dP2;
elseif L == 1.05
dP1 = 2*F*(L/d)*(v^2)*p;
app.PredicteddPEditField.Value = dP1;
dP2 = Exp_dP(1,2);
app.ExperimentaldPEditField.Value = dP2;
I am getting an error "Unrecognized method, property, or field 'value' for class 'matlab.ui.control.DropDown'.". PLEASE HELP

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 4 月 30 日
switch app.FlowrateDropDown.value
Notice you used lower-case V in value . The property names are case-sensitive, so you need to use Value with a capital V

カテゴリ

Help Center および File ExchangeDevelop 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