You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under the heading 'Writing MATLAB Scripts', given that we are focusing of software/data carpentry, I feel it is essential we include a more detailed example for plotting data. While the current example takes the user through the very basics of plotting in MATLAB, instructions on how to co-plot data, specify line styles, and basic manipulation of other plotting parameters will be very useful.
An example code that can introduce the above mentioned concepts using data from 'inflammation-01.csv' is given below:
%% Find the number of rows
no_of_patients = size(patient_data,1);
arr_of_patients = [1:1:no_of_patients]; % This can introduce the concept of building sequential arrays
%% Plot
% Open figure
figure()
hold all
grid on
% Plot data
plot(arr_of_patients,ave_inflammation,'-');
plot(arr_of_patients,max(patient_data, [], 1),'--','linewidth',2);
plot(arr_of_patients,min(patient_data, [], 1),'-.','color','r');
% Label axis
xlabel('Patient Number')
ylabel('Degree of Inflammation')
At minimum we will need to include information about what exactly each function in the above script is doing. Without this, both learners and instructors will be confused. I think that this addition would add a lot of (useful, but not essential) detail to the lesson.
I think it would be great to have the axes labelled. There is some of this in later episodes, but I think it would be good to introduce it a bit earlier. Perhaps a little pointer to the documentation could replace some of the more involved formatting suggestions above?
Under the heading 'Writing MATLAB Scripts', given that we are focusing of software/data carpentry, I feel it is essential we include a more detailed example for plotting data. While the current example takes the user through the very basics of plotting in MATLAB, instructions on how to co-plot data, specify line styles, and basic manipulation of other plotting parameters will be very useful.
An example code that can introduce the above mentioned concepts using data from 'inflammation-01.csv' is given below:
% script analyze.m
patient_data = csvread('inflammation-01.csv');
disp(['Maximum inflammation: ', num2str(max(patient_data(:)))]);
disp(['Minimum inflammation: ', num2str(min(patient_data(:)))]);
disp(['Standard deviation: ', num2str(std(patient_data(:)))]);
ave_inflammation = mean(patient_data, 1);
%% Find the number of rows
no_of_patients = size(patient_data,1);
arr_of_patients = [1:1:no_of_patients]; % This can introduce the concept of building sequential arrays
%% Plot
% Open figure
figure()
hold all
grid on
% Plot data
plot(arr_of_patients,ave_inflammation,'-');
plot(arr_of_patients,max(patient_data, [], 1),'--','linewidth',2);
plot(arr_of_patients,min(patient_data, [], 1),'-.','color','r');
% Label axis
xlabel('Patient Number')
ylabel('Degree of Inflammation')
% Scale axis
set(gca,'xlim',[0 6])
set(gca,'xtick',[0:1:6])
set(gca,'ylim',[0 20])
set(gca,'ytick',[0:4:20])
% Legend
plen = legend('Average Inflammation','Max. Inflammation','Min. Inflammation')
set(plen,'location','NorthEast')
% save plot to disk as png image:
print ('patient_data-01','-dpng','-r400') % Example to specify type and quality of image
The text was updated successfully, but these errors were encountered: