Need help writing this MATLAB assignment I need help writing the code that will
ID: 3833077 • Letter: N
Question
Need help writing this MATLAB assignment
I need help writing the code that will produce the graph that is above, in first image.
MATLAB question
See the four attached pictures above. Note that the .csv file is simply the numVal Array table shown on the first image, in Excel. The graphCholSpring2017.m code starts as this:
oneLine = ' ';
i=1;
numVal = [];
%Open comma-separated file
fh = fopen('CholesterolSpring2017.csv', 'r');
%Read in one line at a time and build the numVal array
while ~feof(fh)
> token = textscan(oneLine,'%d','delimiter', ',');
numVal = [numVal token{i}];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Define length of x - look at the data file (how many points on each line)
%
x = 1: length(numVal);
%Add title
%
title('Cholesterol Spring 2017');
%Prompt for the four line colors and styles
menu1 = ['Choose one of the following marker styles: ',...
' . dot',...
' o circle',...
...
' h hexagram '];
menu2 = ...
marker1 = input(...);
style1 = input(...);
marker2 = ...
style2 = ...
marker3 = ...
style3 = ...
marker4 = ...
style4 = ...
%Prompt for one line width to be used for all 4 lines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set(gca,'XTick',1:length(numVal));
set(gca,'XTickLabel',numVal(1,:));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%On SAME graph, plot Triglycerides, HDL Cholesterol,
%VLDL Cholesterol, and LDL Cholesterol
%Use both the line color and style as entered by user),
%Use marker style according to lab instructions
%Marker face colors must be filled in and the same as the line color
%
%Add a legend in upperright corner
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
As you can see, I am missing A LOT of information in the script. I am extremely confused and have no clue how to solve this. Thank you sincerely for the help...
you will use an xy-scatterplot to graph cholesterol data from the file Cholesterol2016.csv (comma delimited file) as follows: Cholesterol Spring 2017 LDL Cholesterol VLDL Cholesterol HDL Cholesterol Triglycerides 100 2007 2011 2012 2013 2014 2016 2010 You will not create a new file but instead download and edit graphCholSpring2017.m to include the above plot, including marker styles. Code has already been provided that reads the data from Cholesterolspring2017.csv and populates the numVal array: numval array 2006 2007 2008 2009 2010 2011 2012 2013 2014 2016 126 120 109 30 33 42 35 291 221 30 33 47 42 43 36 39 33 39 40 44 43 41 149 164 167 209 176 147 110 151 166 236 You should run the file and in MATLAB's workspace window, and click on numVal to verify the above data.Explanation / Answer
oneLine = ' ';
i=1;
numVal = [];
%Open comma-separated file
fh = fopen('CholesterolSpring2017.csv', 'r');
%Read in one line at a time and build the numVal array
while ~feof(fh)
> token = textscan(oneLine,'%d','delimiter', ',');
numVal = [numVal token{i}];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Define length of x - look at the data file (how many points on each line)
%
x = 1: length(numVal);
%Add title
%
title('Cholesterol Spring 2017');
%Prompt for the four line colors and styles
menu1 = ['Choose one of the following marker styles: ',...
' . dot',...
' o circle',...
...
' h hexagram '];
menu2 = ...
marker1 = input(...);
style1 = input(...);
marker2 = ...
style2 = ...
marker3 = ...
style3 = ...
marker4 = ...
style4 = ...
%Prompt for one line width to be used for all 4 lines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set(gca,'XTick',1:length(numVal));
set(gca,'XTickLabel',numVal(1,:));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%On SAME graph, plot Triglycerides, HDL Cholesterol,
%VLDL Cholesterol, and LDL Cholesterol
%Use both the line color and style as entered by user),
%Use marker style according to lab instructions
%Marker face colors must be filled in and the same as the line color
%
%Add a legend in upperright corner
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.