Create a plot with a text file containing a matrix

I have a matrix that's been read into the program and I need to plot the mean and standard deviation over all users against time for the data.
Can someone help me figure out how to plot that?

1 件のコメント

John Doe
John Doe 2019 年 10 月 9 日
How have you imported the data. What format is it in?
Need to see code and ideally attach the data if you can please. Then happy to answer.

サインインしてコメントする。

回答 (1 件)

Adam Danz
Adam Danz 2019 年 10 月 9 日
編集済み: Adam Danz 2019 年 10 月 11 日

0 投票

Assuming time varies by row and user varies by column, here's a demo you can follow.
% Create a matrix of measurements of users (columns) across time (rows)
m = randn(100,10).*(rand(1,10)*3) + randi(10,1,10);
% Compute the mean and standard dev for each column
mu = mean(m,1,'omitnan');
sd = std(m,[],1,'omitnan');
% Plot results
figure()
% show raw data
h1 = plot((1:numel(mu))-.2, m, 'k+', 'Color', [.7 .7 .7], 'MarkerSize',3, 'DisplayName','raw data');
hold on
% Show mean and std
h2 = errorbar(1:numel(mu), mu, sd, 'o', 'linewidth', 1.5, 'color', 'k', 'DisplayName', 'Mean & std');
% cosmetics
xlabel('User')
ylabel('Measurement (units)')
xlim([0,numel(mu)+1])
legend([h1(1),h2(1)])

カテゴリ

質問済み:

Mia
2019 年 10 月 9 日

編集済み:

2019 年 10 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by