Unit conversion using switch case or else if functions

11 Ansichten (letzte 30 Tage)
Melvinder Singh
Melvinder Singh am 12 Feb. 2020
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 Kommentare
Melvinder Singh
Melvinder Singh am 12 Feb. 2020
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 am 13 Feb. 2020
Bearbeitet: Renato SL am 13 Feb. 2020
How about making a function (documentation here) instead?
With a function, you can declare every input in one line.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Srivardhan Gadila
Srivardhan Gadila am 17 Feb. 2020
valuePlusUnit = "45.3245 ft3";
stringSplit = strsplit(valuePlusUnit);
value = str2num(stringSplit(1))
units = stringSplit(2)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by