Want to Plot a multi line graph in Matlab

1 回表示 (過去 30 日間)
Vartika Agarwal
Vartika Agarwal 2022 年 5 月 31 日
編集済み: thiyagarajan n 2022 年 10 月 8 日
I want to plot a graph like this. How can I implement it in Matlab ?

採用された回答

Sam Chak
Sam Chak 2022 年 5 月 31 日
Like this?
x = 2:0.01:16;
y1 = 15*x + 270;
y2 = (6.6964e-04)*x.^4 - (2.6786e-02)*x.^3 + (9.0625e-01)*x.^2 - (1.2768e+01)*x + 2.7211e+02;
y3 = (4.6503e-03)*x.^5 - (2.4368e-01)*x.^4 + (4.7656e+00)*x.^3 - (4.1525e+01)*x.^2 + (1.6586e+02)*x + 2.0000e+02;
plot(x, y1, 'linewidth', 1.5)
hold on
plot(x, y2, 'linewidth', 1.5)
plot(x, y3, 'linewidth', 1.5)
hold off
grid on
xlabel('Freq')
ylabel('Spectral')
  2 件のコメント
Vartika Agarwal
Vartika Agarwal 2022 年 5 月 31 日
I want a second line which is in blue have some dotted form from 8 to 10
just like this
Sam Chak
Sam Chak 2022 年 5 月 31 日
Modify the code for y1 only:
x1a = 2:0.01:8;
x1b = 8:0.01:10;
x1c = 10:0.01:16;
y1a = 15*x1a + 270;
y1b = 15*x1b + 270;
y1c = 15*x1c + 270;
plot(x1a, y1a, 'b-', 'linewidth', 1.5)
hold on
plot(x1b, y1b, 'b--', 'linewidth', 1.5)
plot(x1c, y1c, 'b-', 'linewidth', 1.5)

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

その他の回答 (1 件)

thiyagarajan n
thiyagarajan n 2022 年 10 月 8 日
編集済み: thiyagarajan n 2022 年 10 月 8 日
x = [......]; % use values of observations
y1 = [.....]; % use values of observations or form expression
y2 = [.....]; % use values of observations or form expression
y3 = [.....]; % use values of observations or form expression
figure(1);
plot(x, y1, x, y2, x, y3);
xlabel('Frequency Slots --->');
ylabel('Spectral Efficiency');
legend('Average User rate','Fair Spectrum Sharing','No Spectrum Sharing');

カテゴリ

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

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by