Unit conversion using switch case or else if functions

조회 수: 2 (최근 30일)
Melvinder Singh
Melvinder Singh 2020년 2월 12일
답변: Srivardhan Gadila 2020년 2월 17일
Im supposed to use the switch case method or the else if method to solve this question. Anyone has any ideas on how to solve this?
  댓글 수: 5
Melvinder Singh
Melvinder Singh 2020년 2월 12일
Like to make it in such a way that I only need to input the starting value and unit together and not separately.
Renato SL
Renato SL 2020년 2월 13일
편집: Renato SL 2020년 2월 13일
How about making a function (documentation here) instead?
With a function, you can declare every input in one line.

댓글을 달려면 로그인하십시오.

답변 (1개)

Srivardhan Gadila
Srivardhan Gadila 2020년 2월 17일
valuePlusUnit = "45.3245 ft3";
stringSplit = strsplit(valuePlusUnit);
value = str2num(stringSplit(1))
units = stringSplit(2)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by