Write a function that receives an input argument of a number of kilometers (km) and will output the conversions into both miles (mi) and US nautical miles (n.m.). Use the conversions: 1 km = 0.621 mi and 1 km = 0.540 n.m.
    10 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
Write a function that receives an input argument of a number of kilometers (km) and will output the conversions into both miles (mi) and US nautical miles (n.m.). Use the conversions: 1 km = 0.621 mi and 1 km = 0.540 n.m.
1 comentario
  Steven Lord
    
      
 el 19 de Oct. de 2016
				Show what you've done to try to solve this problem and ask a specific question about where you're stuck and you may receive some guidance.
Respuestas (5)
  James Tursa
      
      
 el 21 de Oct. de 2016
        
      Editada: James Tursa
      
      
 el 21 de Oct. de 2016
  
      1) Create a function file called myconversion.m in your working directory. E.g.,
edit myconversion.m
2) Put the following code into this file:
function [x_mi,x_nm] = myconversion(x_km)
% Insert your code here to convert x_km to x_mi
% Insert your code here to convert x_km to x_nm
return
end
Insert your code for the conversions into the places indicated. Also add comments to this file to state the purpose of the function, show the calling syntax, and explain what the inputs and outputs are.
0 comentarios
  Christian Hernandez
 el 1 de Oct. de 2019
        function [x_mi,x_nm] = myconversion(x_km)
% Insert your code here to convert x_km to x_mi
% Insert your code here to convert x_km to x_nm
return
end
1 comentario
  Walter Roberson
      
      
 el 1 de Oct. de 2019
				It is not clear how this differs from James Tursa's guideance ?
  Najm
 el 10 de Nov. de 2022
        function [x_mi,x_nm] = myconversion(x_km) % Insert your code here to convert x_km to x_mi % Insert your code here to convert x_km to x_nm return end
0 comentarios
  Yasmin Eady
 el 23 de Sept. de 2024
        function [miles, nmiles] = convert(k)
    km_to_miles = 0.621;
    km_to_nmiles = 1/1.852;
    miles = k * km_to_nmiles;
    nmiles = k *km_to_miles;
end
This is what I did. I want to know if this is right. 
1 comentario
  Yasmin Eady
 el 23 de Sept. de 2024
				I think this is for another problem but I wanted to know if this is the right approch. 
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







