Bar plot from different .csv files

조회 수: 1 (최근 30일)
Paola Morales Carvajal
Paola Morales Carvajal 2022년 2월 27일
편집: Scott MacKenzie 2022년 2월 28일
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
Paola Morales Carvajal
Paola Morales Carvajal 2022년 2월 27일
Scott MacKenzie
Scott MacKenzie 2022년 2월 27일
편집: Scott MacKenzie 2022년 2월 28일
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');

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by