Prompt User Input for a Graph

2 次查看(过去 30 天)
Hi all.
I am struggling with a Lab assignment that requires you to prompt for user input to create the graph itself.
clear
clc
clf
oneLine = ' ';
i=1;
numVal = [2006 95 30 42 149
2007 109 33 43 164
2008 95 33 36 167
2009 95 42 39 209
2010 117 35 33 176
2011 114 29 39 147
2012 120 22 40 110
2013 126 30 44 151
2014 120 33 43 166
2016 109 47 41 236];
%Open comma-separated file
fh = fopen('Cholesterol.csv', 'r');
%Read in one line at a time and build the numVal array
while ~feof(fh)
oneLine = fgetl(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)
%
%Add title
%
%Prompt for the four line colors and styles
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This is the code we must edit, provided by the instructor.
Screen Shot 2019-04-22 at 8.40.13 PM.png
How would I implement these user prompts into the code above? Thanks
  3 个评论
Ashwin Sivalingam
Ashwin Sivalingam 2019-4-23
I am able to create the prompt, but it is the process after that that I don't know what to do. For ex, making it iterative so that after the final prompt it results in the graph being displayed.
Walter Roberson
Walter Roberson 2019-4-23
types = {'LDL', 'VLDL', 'HDL'};
for ind = 1 : length(types)
this_type = types{ind};
fprintf('For %s Cholesterol choose one of the following':, this_type);
fprintf('g ground\nr radiccio\nc celery\n');
letter{ind} = input(' ', 's');
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by