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.

 채택된 답변

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 Exchange에서 Line 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