Skip to main content

Posts

Showing posts with the label kilometers

Convert from miles per hour to kilometers per hour and vice versa using Matlab

Problem Write a Matlab program to convert from miles per hour(mph) to kilometers per hour(kph) if the user gives the input in mph and from kph to mph if the user gives input in kph. (Hint: Ask the user to enter the value first and then ask the user to select the units giving options.). The conversion factors are as follows: Miles per hour(mph) to Kilometers per hour(kph) conversion Kilometers per hour(kph) to Miles per hour(mph) conversion You can get to know about the speed and its units Speed - Wikipedia . Solution This problem is similar to our previous post: Convert Temperatures Celsius Fahrenheit using Matlab . Hint has also been given in the question itself and I suggest you to directly see program section and for detailed explanation then see explanation section. Some of the concepts you need to know to solve this problem are as follows: 1) Request User input Matlab 2) fprintf function in Matlab 3) variables in Matlab 4) if elseif else statements in Ma...