Unit conversion using switch case or else if functions
조회 수: 2 (최근 30일)
이전 댓글 표시

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
답변 (1개)
Srivardhan Gadila
2020년 2월 17일
For "Like to make it in such a way that I only need to input the starting value and unit together and not separately" you can make use of strsplit, str2num functions as follows:
valuePlusUnit = "45.3245 ft3";
stringSplit = strsplit(valuePlusUnit);
value = str2num(stringSplit(1))
units = stringSplit(2)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!