Effacer les filtres
Effacer les filtres

Plotting a Piecewise function?

4 vues (au cours des 30 derniers jours)
Jean
Jean le 5 Déc 2012
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.

Réponses (1)

Matt Fig
Matt Fig le 5 Déc 2012
Modifié(e) : Matt Fig le 5 Déc 2012
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),'.')

Catégories

En savoir plus sur Manage Products dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by