I need help implementing Challenges into my code. Please help!
조회 수: 7 (최근 30일)
이전 댓글 표시
% 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
답변 (1개)
Voss
2022년 4월 1일
편집: Voss
2022년 4월 1일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!