필터 지우기
필터 지우기

Plotting a Piecewise function?

조회 수: 4 (최근 30일)
Jean
Jean 2012년 12월 5일
Hey guys. I need to graph a piecewise function in MATLAB and I don't know how to do it. On top of that, it is also in radians:
f(θ)
=
(80/π²) θ, -π/2 ≤ θ ≤ π/2;
(80/π) - (80/π²) θ, π/2 ≤ θ ≤ 3π/2
How do I graph it in MATLAB? And other than that, is there a way in MATLAB that I can take that function and turn it into time instead of radians? Thanks a lot.

답변 (1개)

Matt Fig
Matt Fig 2012년 12월 5일
편집: Matt Fig 2012년 12월 5일
First define this in an M-file:
function [F] = myfunc(thet)
% help
F = zeros(size(thet));
idx = -pi/2 <= thet & thet <=pi/2;
F(idx) = 80*thet(idx)/pi^2;
idx = pi/2 <= thet & thet <=3*pi/2;
F(idx) = 80/pi*(1 - thet(idx)/pi);
Now from the command line:
>> t = linspace(-pi/2,3*pi/2,1000);
>> plot(t,myfunc2(t),'.')

카테고리

Help CenterFile Exchange에서 Manage Products에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by