problem in writing matlab code (To Plot)

I want plot the function A versus x, can't write the program for the following algorithm.
A= K for x <= 0; K is a constant
A= K/2 (1+cos x) for 0<x<50;
A= 0 for x >= 50
i have used the if elseif else end statement, but not not succeed.

1 件のコメント

Thorsten
Thorsten 2015 年 6 月 30 日
Please show us your code.

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

 採用された回答

Thorsten
Thorsten 2015 年 6 月 30 日

0 投票

K = 1;
x = linspace(-100,100);
A = K/2*(1 + cos(x));
A(x<=0) = 1;
A(x>=50) = 0;
plot(x,A)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2015 年 6 月 30 日

回答済み:

2015 年 6 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by