how can i plot this piceise function?

조회 수: 2 (최근 30일)
Jesper Christensen
Jesper Christensen 2017년 12월 1일
댓글: Jesper Christensen 2017년 12월 1일
>> x = 0 : 0.01 : 25;
for k = 1 : length(x)
if x < 6.7
y(k) = 1200*x;
elseif x >= 6.7 && x < 12
y(k) = 83*x;
else
y(k) = -1200*x;
end
end
plot(x, y);
grid on;

답변 (1개)

Torsten
Torsten 2017년 12월 1일
x = 0 : 0.01 : 25;
for k = 1 : length(x)
if x(k) < 6.7
y(k) = 1200*x(k);
elseif x(k) >= 6.7 && x(k) < 12
y(k) = 83*x(k);
else
y(k) = -1200*x(k);
end
end
plot(x, y);
grid on;
Best wishes
Torsten.
  댓글 수: 1
Jesper Christensen
Jesper Christensen 2017년 12월 1일
i want the funktion to raise when x 0-->6.7 and stay 83 from x 6.7 --> 12 and then drop when above 12

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by