Scatterplot from .mat file data with loop
显示 更早的评论
How do I make a scatter plot from a .mat file that looks like this? 

I have a .mat file with data from 15 petri dish colonies. Each column has 10 days of population data. There are 15 rows. I need each dish to plot its points vertically and then draw a line with thickness 3 that is the average of the days. I have been told to use a loop but I'm completely stuck on even starting.
回答(2 个)
Star Strider
2020-10-31
Try something like this:
Colonies = rand(15,10); %Days = 15, Colonies = 10
MeanColonies = mean(Colonies,2);
Days = 1:15;
figure
plot(Days, Colonies, 'p')
hold on
plot(Days, MeanColonies, 'LineWidth',2)
hold off
.
A = rand(15,8) ; % random data for demo
[m,n] = size(A) ;
% Get mean
M = mean(A) ;
X = repmat(1:n,m,1) ;
scatter(X(:),A(:),[],A(:))
hold on
plot(1:n,M,'k')
类别
在 帮助中心 和 File Exchange 中查找有关 Box Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!