Unit conversion using switch case or else if functions

8 visualizaciones (últimos 30 días)
Melvinder Singh
Melvinder Singh el 12 de Feb. de 2020
Respondida: Srivardhan Gadila el 17 de Feb. de 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 comentarios
Melvinder Singh
Melvinder Singh el 12 de Feb. de 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 el 13 de Feb. de 2020
Editada: Renato SL el 13 de Feb. de 2020
How about making a function (documentation here) instead?
With a function, you can declare every input in one line.

Iniciar sesión para comentar.

Respuestas (1)

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

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by