plotting mutiple curve in the same graph

16 ビュー (過去 30 日間)
Chun Fai Leung
Chun Fai Leung 2022 年 7 月 16 日
コメント済み: Star Strider 2022 年 7 月 29 日
I would like to plot a graph for the table. So I use the following code.
clear
dataset = xlsread('modifiedDataset.xlsx','Sheet1');
x = dataset(:,6);
y = dataset(:,11);
plot(x,y);
But for column G, the number are actually the particle numbers. I would like to plot several curve in the same graph if possible, each curve for each particle respectively. In this case, there are 9 particles. Is there any code that could help me identify the particle number and plot the curves respectively. I'm new to MATLAB, sorry about that. I would much appreciate your help. Thank you.

採用された回答

Star Strider
Star Strider 2022 年 7 月 16 日
Here are two options —
dataset = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1067780/modifiedDataset.xlsx');
x = dataset(:,6);
y = dataset(:,11);
p = dataset(:,7);
up = unique(p);
figure
hold on
for k = 1:numel(up)
Lv = p == up(k);
plot(x(Lv), y(Lv), 'DisplayName',sprintf('Particle %d',up(k)))
end
hold off
grid
legend('Location','best')
NrSP = numel(up);
figure
hold on
for k = 1:numel(up)
subplot(5,2,k)
Lv = p == up(k);
plot(x(Lv), y(Lv))
grid
ylim([0 1.4])
title(sprintf('Particle %d',up(k)))
end
hold off
There are other possibilities as well.
.
  12 件のコメント
Chun Fai Leung
Chun Fai Leung 2022 年 7 月 29 日
wow sir. It looks so much better and exactly what I want. I do want to exclude the extreme values and delete the rows of data, apparently you have also done it already.So when I redo the experiment again with different light intensity, should I always check for extreme values and exclude them again. Thank you so much sir.
Star Strider
Star Strider 2022 年 7 月 29 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by