Bar plot from different .csv files

1 vue (au cours des 30 derniers jours)
Paola Morales Carvajal
Paola Morales Carvajal le 27 Fév 2022
I have 15 .csv files which column 2 is in mm and column 3 is the Newton where I ran three times for the same set. I want the script to read all the files and to make a bar graph where I take the average of each set and calculate the standard deviation. I appreaciate if someone can help me.
  3 commentaires
Paola Morales Carvajal
Paola Morales Carvajal le 27 Fév 2022
Scott MacKenzie
Scott MacKenzie le 27 Fév 2022
Modifié(e) : Scott MacKenzie le 28 Fév 2022
OK, that's a start. But, it's not clear what you want each "bar graph" to look like. I just looked in the first file. The 1st column contains timestamps for the measurements. The 2nd and 3rd columns contain the measurements for extension (mm) and load (Newtons), respectively. I created some plots of the data in the 2nd and 3rd columns vs. time. Below, the 1st two plots (top row) are line plots and the 2nd two (bottom row) are bar charts showing the means and standard deviations in error bars. I'm not sure that bar graphs are appropriate, given the trends that are evident in the line charts. Please explain in a bit more detail what type of output you want to create. It's also not clear how you want to combine the data from the 15 files. Please explain.
f = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/909015/S1_2_8_25_Specimen_RawData_1.csv';
M = readmatrix(f, 'range', 'a6');
tiledlayout(2,2);
nexttile;
plot(M(:,1), M(:,2));
xlabel('Time (s)'); ylabel('Extension (mm)');
nexttile;
plot(M(:,1), M(:,3));
xlabel('Time (s)'); ylabel('Load (Newtons)')
nexttile;
m1 = mean(M(:,2));
bar(m1);
hold on;
ax = gca;
ax.XTickLabel = {'S1\_2\_8\_25'}; ylabel('Extension (mm)');
errorbar(m1, std(M(:,2)), 'color', 'k');
nexttile;
m2 = mean(M(:,3), 'omitnan');
bar(m2);
hold on;
ax = gca;
ax.XTickLabel = ('S1\_2\_8\_25'); ylabel('Load (Newtons)');
errorbar(m2, std(M(:,3), 'omitnan'), 'color', 'k');

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by