how to plot this function x(t) = r(t+2)- r(t+1)- r(t-1)+ r(t-2);
knowing that t = -3:2 ;
help please ??

답변 (1개)

Atsushi Ueno
Atsushi Ueno 2021년 4월 14일

0 개 추천

t = -3:2;
plot(t, x(t))

댓글 수: 9

Ahmed Amer
Ahmed Amer 2021년 4월 14일
what about r ???
You need following as x.m file:
function out = x(t)
out = r(t+2)- r(t+1)- r(t-1)+ r(t-2);
end
and you also need following as r.m file:
function out = r(t)
out = 0; % something your function I don't know
end
Ahmed Amer
Ahmed Amer 2021년 4월 14일
here is the function
Ahmed Amer
Ahmed Amer 2021년 4월 14일
I need to plot it
Atsushi Ueno
Atsushi Ueno 2021년 4월 14일
편집: Atsushi Ueno 2021년 4월 14일
Thank you. I understand that r() is a ramp function and maybe u() is a step function.
Also, you should check this similar question.
You don't need m-file for each function as I said by using anonymous function like other Q&A above.
t = -3:2;
r = @(t) t.*(t>=0);
x = @(t) r(t+2)- r(t+1)- r(t-1)+ r(t-2);
plot(t, x(t));
Ahmed Amer
Ahmed Amer 2021년 4월 14일
so how i can plot it could you please write the code
Atsushi Ueno
Atsushi Ueno 2021년 4월 14일
편집: Atsushi Ueno 2021년 4월 14일
I've written the code above. I will repeat it again.
t = -3:2;
r = @(t) t.*(t>=0);
x = @(t) r(t+2)- r(t+1)- r(t-1)+ r(t-2);
plot(t, x(t));
Ahmed Amer
Ahmed Amer 2021년 4월 14일
sorry i did not saw it ,thanks

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

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2021년 4월 14일

댓글:

2021년 4월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by