Filter löschen
Filter löschen

Error matrix dimensions must agree

1 Ansicht (letzte 30 Tage)
Craig Anthony PIllay
Craig Anthony PIllay am 4 Sep. 2019
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Sep. 2019
strcmp for comparing character vectors.
  1 Kommentar
Craig Anthony PIllay
Craig Anthony PIllay am 4 Sep. 2019
Thank you so much.
it was such a simple answer.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by