필터 지우기
필터 지우기

Convert graph figure to equation

조회 수: 12 (최근 30일)
collegestudent
collegestudent 2023년 1월 20일
댓글: Torsten 2023년 1월 20일
I am trying to write the equation of the graph and plot it.
So far I have written this equation, however when I plot it, there is a point at (-3,-3) and I am not sure why. I need to plot it as a continuous time signal.
n = -6:6;
x = @(n) n.*((n>-4)&(n<=-2))+4*(n==-2)+(-2)*(n==2)+0*(n==4);
plot(n,x(n));
  댓글 수: 1
Adam Danz
Adam Danz 2023년 1월 20일
@collegestudent I edited your question to run your code so that it produces the plot.

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

채택된 답변

Torsten
Torsten 2023년 1월 20일
x = @(t) (t+4).*(t>-4 & t<-2) + (t-4).*(t>2 & t<4);
t = -6:0.01:6;
plot(t,x(t))
grid on
  댓글 수: 2
collegestudent
collegestudent 2023년 1월 20일
Do you know why when I try to evaluate the equation of x(t) = 2x(t-2) I get the error of "Operator '*' is not supported for operands of type 'function_handle'."
x2 = (2*x)*(t-2);
Torsten
Torsten 2023년 1월 20일
x2 = 2*x(t-2)
instead of
x2 = (2*x)*(t-2);
x(t-2) stands for: evaluate function x at t-2, not for: multiply x by t-2.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by