Unit conversion using switch case or else if functions

3 次查看(过去 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 个评论
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