How do I create more than one plot at a time in a script?

We are taking multiple measurements from multiple instrument channels. I would like to create a histogram of values by channel, then another histogram of all of the data combined. How do you create more than one plot in a script? I'm attaching my code, it creates a single plot of the combined data.
for angle = 90:10:270
rows = nonInvData.actAngle == angle & nonInvData.orientation == orientation;
dataVals = nonInvData(rows, ["channel","pa13"]);
for chn = 0:39
rows = dataVals.channel == string(chn);
data = dataVals(rows, "pa13");
h(angle) = histogram(data.pa13,20,'DisplayName',string(chn),"BinMethod","integers")
hold on
end
hold off
legend show
h(angle+1) = histogram(dataVals.pa13,20,'DisplayName',string(chn),"BinMethod","integers")
end

 採用された回答

Adam Danz
Adam Danz 2019 年 4 月 15 日
編集済み: Adam Danz 2019 年 4 月 17 日

0 投票

Create the different axes prior to your loops. Then specify which axes should be used for each histogram. Here's an example that produces two axes (subplots) within one figure (you could also produces them in different figures).
figure
ax1 = subplot(2,1,1);
ax2 = subplot(2,1,2);
histogram(ax1, .......)
histogram(ax2, .......)
To put them in separate figures
figure
histogram(...)
figure
histogram(...)

2 件のコメント

Brian Mullen
Brian Mullen 2019 年 4 月 17 日
How would I put them into separate figures?
Adam Danz
Adam Danz 2019 年 4 月 17 日
I updated my answer to demonstrate separate figures.
Another alternative:
figure
ax1 = axes();
figure
ax2 = axes();
histogram(ax1, .......)
histogram(ax2, .......)

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2019a

質問済み:

2019 年 4 月 15 日

コメント済み:

2019 年 4 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by