How to code this in matlab code.

Write a MATLAB program to plot with legend and grids the (Sine wave) in the left side of the window using green continuous line and (Cosine wave) in the right side of the window using black dashed line.

1 件のコメント

Stephen23
Stephen23 2021 年 7 月 13 日
@Fathima Nasha: what have you tried so far?

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

回答 (1 件)

Jogesh Kumar Mukala
Jogesh Kumar Mukala 2021 年 7 月 13 日

0 投票

Hi,
Assuming you want to plot both graphs side by side in a same window, you need to go through subplot, plot, grid and legend functions of MATLAB. These functions can help you in plotting the required graphs as per your choice. A sample code is provided below for your reference.
subplot(2,2,1)
t = 0:0.01:(2*pi);
x=sin(t);
plot(t,x,'Color','g')
grid on
legend('sin(t)')
subplot(2,2,2)
t = 0:0.01:(2*pi);
y=cos(t);
plot(t,y,'Color','k','LineStyle','--')
grid on
legend('cos(t)')

カテゴリ

ヘルプ センター および File ExchangeGraphics Object Properties についてさらに検索

タグ

質問済み:

2021 年 7 月 13 日

回答済み:

2021 年 7 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by