Can I plot two figures simultaneously but with less data for the second figure?

Hi there!
Let's say I want to plot the first figure for theta = linspace(0, 2*pi, 1001), but for the second figure I only want to plot for theta = linspace(0,pi,20).
Is it possible to do this automatically?
My current workflow is manually changing the theta = linspace values each time I make the two plots, but I was wondering if there was a solution to automate the plotting in which I do not have to keep switching the values of theta -- so that plotting once gets me both plots correctly.
Thanks!

 採用された回答

Walter Roberson
Walter Roberson 2024 年 12 月 24 日
編集済み: Walter Roberson 2024 年 12 月 25 日
Well, you can... but it isn't worth the trouble.
N1 = 1001;
N2 = 20;
theta = linspace(0, 2*pi, N1);
[~, pi_idx] = min(abs(theta-pi));
theta2_idx = round(linspace(1, pi_idx, N2));
theta2 = theta(theta2_idx);
plot(theta, Y1, theta2, Y2)
Compare to
theta = linspace(0, 2*pi, 1001);
theta2 = linspace(0, pi, 20);
plot(theta, Y1, theta2, Y2);

1 件のコメント

Noob
Noob 2024 年 12 月 25 日
Hi Walter!
Ok, let me not think about this anymore, and I'll instead move on and keep working, and just adjust the data, and plot twice. It is a fast enough workflow.
Thanks as always -- goodnight!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2024b

タグ

質問済み:

2024 年 12 月 24 日

編集済み:

2024 年 12 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by