フィルターのクリア

Error matrix dimensions must agree

1 回表示 (過去 30 日間)
Craig Anthony PIllay
Craig Anthony PIllay 2019 年 9 月 4 日
I have an issue when running a check of units when a button is pushed.
I have a drown down menu for units and my code should calculate the the actual number depending on what units is selected.
for example if m3/hr is chosen then the fllowrate is divided by 3600 converting to m3/s however if ft3/s is chosen then the flowrate is converted to m3/s
When i run the code intially if i donot change the units there is no error however if i change the drown menu i.e. the units it gives the error.
Matrix dimensions must agree.
I understand the error is because on of my variables is a being treated like a matrix however i am not sure how to fix.
Error occurs on line 5
I have tried to run the code in a value change function however the same problem occurs.
FlowrateUnitsOne = ['m' char(179) '/hr'];
FlowrateUnitsTwo = ['ft' char(179) '/hr'];
FlowrateUnitscheck = app.FlowrateUnits.Value;
app.FlowrateUnits.ValueChangedFcn;
if eq(FlowrateUnitscheck,FlowrateUnitsOne)
Flowrate = app.FlowrateofLiquidEditField.Value/(2.2046*3600);
app.Label.Text = sprintf('%d',Flowrate);
elseif eq(FlowrateUnitscheck,FlowrateUnitsTwo)
Flowrate = app.FlowrateofLiquidEditField.Value/(3600);
app.Label.Text = sprintf('%d',Flowrate);
end

採用された回答

Walter Roberson
Walter Roberson 2019 年 9 月 4 日
strcmp for comparing character vectors.
  1 件のコメント
Craig Anthony PIllay
Craig Anthony PIllay 2019 年 9 月 4 日
Thank you so much.
it was such a simple answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by