I need help implementing Challenges into my code. Please help!
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
% Challenge 1: Update the figure to use the corresponding color stored in the variable, symList. For example, if the user selected Run 14, then % the symbol color would be a cyan circle with a black border, i.e.,
% Challenge 2: Implement a data validation strategy to require the user to select an experiment when presented with the list of experiments
% (i.e., you can no longer assume the user will pick an option)
% Challenge 3: After the user plots the first figure, ask the user if they want to plot another figure. If the user selects 'Yes', then re-present the list % of experiments to choose from
%choData: col 1: Time (t) [hours]
% col 2: Viable Cell Density (VCD) [cells/mL] -- Run 7
% col 3: Viable Cell Density (VCD) [cells/mL] -- Run 14
% col 4: Viable Cell Density (VCD) [cells/mL] -- Run 26
% -----< 1) Housekeeping commands >-----
clear
clc
close all
% -----< 2) Read data as a numeric matrix >-----
D = readmatrix('CHOcell_VCD_data2.xlsx')
% -----< 3) Set basic graph settings >-----
expList = {'Run 7', 'Run 14', 'Run 26'};
symList = {'g', 'c', 'y'}; % symList used for *Challenge 1*
% -----< 4) Ask user to select one of the experiments >-----
experiment = listdlg('PromptString','Pick a experiment','ListString',expList,'SelectionMode','single');
color = listdlg('PromptString','Pick a color','ListString', symList,'SelectionMode','single');
% -----< 5) Create semilog plot >-----
figure('Color','w')
semilogy(D(:,1), D(:,experiment+1),'ok')
grid on
ylim([10^5 10^8])
mytitle = sprintf('Experiment: %s - aslin', expList{experiment});
title(mytitle)
xlabel('Time (t) [hours]')
ylabel('Viable Cell Density (VCD) [cells/ml]')
% Challenge 1
a = symList{color}
hold on
plot(D(:,experiment+1),'MarkerFaceColor', 'a') % this line is challenge #1 but I cannot get it to work.
% Challenge 2
% Challenge 3
0 Kommentare
Antworten (1)
Voss
am 1 Apr. 2022
Bearbeitet: Voss
am 1 Apr. 2022
For Challenge #1, don't put quotes around a because a is a variable storing the value of the MarkerFaceColor you want to use ('g', 'c', or 'y', depending on the user's selection), whereas 'a' with the quotes is a single character (specifically a letter) that does not refer to a color like 'g', 'c', 'y', 'r', 'b', 'k', 'm', and 'w' do. (Also, don't forget to specify the x-coordinates of the line by using D(:,1) just like you did in semilogy a few lines above.)
plot(D(:,1),D(:,experiment+1),'ok','MarkerFaceColor',a) % could also use semilogy again here
0 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!