MATLAB Write a function that takes no arguments and returns 2 variables, mpg and
ID: 3741619 • Letter: M
Question
MATLAB Write a function that takes no arguments and returns 2 variables, mpg and car_model.
The function will read the file ‘porsche.xlsx’ and will get ONLY the miles per gallon data (mpg) and the car line data (car_model).
Find the car(s) with miles per gallon greater than 32.
Create a new MS Excel file, ‘mpg322007’ with the selected data.
If you have Matlab version 2016b, you can write the function on the same script as the main program and submit only one M-file. Lab_08_yourName.
Explanation / Answer
SAVE THE FOLLOWING CODE IN MATLAB AND GET THE RESUTLS-
clc
clear
close all;
values={37, 29, 40 ; 34, 25, 'x' ; 47, 38, 79};
Car_Truck={'C1','C2','C3'};
xlswrite('myExample.xlsx',[Car_Truck; values]);
filename = 'myExample.xlsx';
A=xlsread(filename);
B=A>32;
disp('The cars with miles greater than 32 are')
disp(5)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.