필터 지우기
필터 지우기

plot this alternative function

조회 수: 2 (최근 30일)
HADIMARGO
HADIMARGO 2019년 6월 27일
답변: Steven Lord 2019년 6월 27일
how could i alternative my function? here is my code:
clc
clear all
t=-5:0.01:5;
f=(t+2).*(t>-2)-(t+2).*(t>-1)+(1).*(t<=1)-(1).*(t<=-1)+(2-t).*(t>1)-(2-t).*(t>=2)
figure (1)
plot (t,f);
axis([-6,6,-1,3])
the correct shape and my shape:
Untitled-1.jpg

답변 (1개)

Steven Lord
Steven Lord 2019년 6월 27일
Are you certain you've implemented the formula correctly? Your expected result has a very different value for t = -5 than for t = -3, but none of the logical terms in your code differ in value for t = -5 and t = -3 and none of the numeric terms by which those logical terms are multiplied depend upon t.
For t = -3, your function evaluates to 1-1. The following terms are the only ones that are something times true.
(1).*(t<=1)-(1).*(t<=-1)
For t = -5, your function evaluates to 1-1. The following terms are the only ones that are something times true.
(1).*(t<=1)-(1).*(t<=-1)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by