plot two curves different size

8 ビュー (過去 30 日間)
Guendouz walid
Guendouz walid 2023 年 4 月 13 日
コメント済み: Guendouz walid 2023 年 4 月 15 日
How to draw two different size curves on the same figure ?
thank's

回答 (1 件)

Amit Dhakite
Amit Dhakite 2023 年 4 月 13 日
編集済み: Amit Dhakite 2023 年 4 月 13 日
Hi Guendouz,
In order to draw two different size curves on the same figure, you can use tiledlayout() and then specify two curves that you want to plot on that, it will automatically take care of their different sizes and scale the plots accordingly. An example to do so is provided below:
% Creating plots of two different sizes
x1 = linspace(0,10,50);
x2 = linspace(0,20,40);
y1 = sin(x1);
y2 = cos(x2);
% To represent 2 rows and 1 column on same figure
tiledlayout(2,1)
% Top plot
nexttile
plot(x1,y1)
title('Plot 1')
% Bottom plot
nexttile
scatter(x2,y2)
title('Plot 2')
To know more about combining multiple plots, kindly refer to the following links:
  1. Combine Multiple Plots: https://www.mathworks.com/help/matlab/creating_plots/combine-multiple-plots.html
  2. tiledlayout(): https://www.mathworks.com/help/matlab/ref/tiledlayout.html
  1 件のコメント
Guendouz walid
Guendouz walid 2023 年 4 月 15 日
Thank you Amit

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

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by