This is in Matlab midterm1.csv is in an excel file with these variables and numb
ID: 3581160 • Letter: T
Question
This is in Matlab
midterm1.csv is in an excel file with these variables and numbers
9a. File Management
%
% To prepare to create a file with this content in this format:
%
% A ,BB ,CCC
% 101 ,01.2345 ,2.3e-02
% 102 ,02.2345 ,2.4e-02
% 103 ,03.2345 ,2.5e-02
%
% * Create a variable |fname| called 'midterm1.csv'
% * Create a |header| string with the entire header line, including commas
% * Create a numeric matrix called |data| containing the numbers above
%% 9b.
% Use the file open command with the name stored in |fname| with write
% permissions. Assign the output file identifier to variable |fid|.
%% 9c.
% File print format to the file identifier above just the headers stored in
% variable |names|. Be sure to include the commas and a new line.
%% 9d.
% File print format to the file identifier above the numeric values in
% matrix |data| to have the exact format specified above. Recall you may
% need a transpose for data.
%% 9e.
% Use the file close command to close the file identifier, fid.
%% 9f.
% Use the |dataset| command to open the 'XLSFile' as named in variable
% |fname|. Save the data in a variable called |dset|.
%
% Note: If you were unable to create the file from the steps above, you can
% use the file 'midterm1.csv' provided on BeachBoard
%% 9g.
% Extract the |dset| information in the BB column using matrix index
% notation
A ,BB ,CCC 1 01 ,01 .2345 ,2.30e-02 1 02 ,02 .2345 ,2.40e-02 1 03 ,03 .2345 ,2.50e-02Explanation / Answer
fname = 'midterm1.csv';
header = 'A ,BB ,CCC';
data = [101,01.2345 ,2.3e-02;102,02.2345 ,2.4e-e02;103,03.2345 ,2.5e-02];
fid = fopen(fname,'w');
fprintf(fid,header);
fprintf(fid,data);
fclose(fid);
dset = dataset('File','midterm1.csv');
dset.Properties.VarNames{2}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.