필터 지우기
필터 지우기

Trying to create a script that will plot a unit step fuction with an argument depending on two variables.

조회 수: 4 (최근 30일)
This is the function I am trying to create and plot in MATLAB, so far I have this code which is not correct I believe.
x = (-50:0.01:50);
a = -50:.01:50;
impulse = x==0;
us = x>=0;
Fx = x/a*(us.*(x-a)-us.*(x-2*a));
plot(x, Fx)
Which creates this graph.
Which isn't correct either. I'm looking at my equation and I know it isn't going to give me the correct output, but I'm not sure what coding wizardry I should use to accomplish this task. Perhaps I'm not thinking of the math itself properly either.

채택된 답변

Walter Roberson
Walter Roberson 2020년 10월 6일
us = @(x) x>=0;
Fx = x/a.*(us(x-a)-us(x-2*a));

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by