Unit conversion using switch case or else if functions

11 ビュー (過去 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 Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by