필터 지우기
필터 지우기

Error matrix dimensions must agree

조회 수: 1 (최근 30일)
Craig Anthony PIllay
Craig Anthony PIllay 2019년 9월 4일
댓글: 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 CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by