Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The first one is the question and the second one is the sample Work with your group to write an interactive MATLAB program to convert
The first one is the question and the second one is the sample
Work with your group to write an interactive MATLAB program to convert a yard stick to a meter stick. The program should plot the results in a graph, and interact with user by requesting the input in inches (a yard stick is 36 inches), convert the input into centimeters (1 inch = 2.54 cm), and mark it on the plot with 'o'. Create a new M-file in your Current Folder, name it as Li_GA.m, and write comments for each line of code. After you save and run the M-file, you should have a plot similar to Fig. 1-9 40 35 30 25 yard stick (in) 20 15 101 5 o 20 80 40 60 meter stick (cm) 100 To perform this exercise, copy and paste the following code, exactly as it is, into a new M-file, and name it L1 Exercise_5.m. % program to convert Celsius temperature to Fahrenheit temperature clear; clf; % clears figure $ Create variable tempc to be used as an argument in the mathematical % function for Fahrenheit temperature tempf as a function of tempo tempc = linspace(0, 100, 20); tempf = 9/5* tempc+32; % plot the function plot (tempc, tempf) xlabel('Temperature in degrees C','fontsize', 18) ylabel('Temperature in degrees F','fontsize', 18) set (gca,'fontsize', 18); grid on % request user to specify temperature in Centigrade and wait for input hold on tempo = input('What is the temperature in Centigrade?...'); tempf = 9/5* tempc+32; % convert input into Fahrenheit tempf % print results on command window plot(tempc, tempf,'o') % mark it on the plot with 'o' After you save and run the M-file, you should have a plot similar to Fig. 1-7, and the following lines will appear in your prompt window: >> L1_Exercise_5 What is the temperature in Centigrade?... 250 250 200 200 150 150 Temperature in degrees F Temperature in degrees F 100 100 X 5 Y 41 50 50 0 0 0 20 40 60 80 100 Temperature in degrees C Fig. 1-7: Results in Exercise 5 before user input 20 40 60 80 100 Temperature in degrees C Fig. 1-8: Results in Exercise 5 after user inputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started