Plotting a function with three regions
Afficher commentaires plus anciens
Hi,I have been plotting various functions on matlab but I can’t wrap my head around this one, how can I write or plot this function when it has three values in three regions?

1 commentaire
Use "piecewise" or define
g = @(n) -3*(n>=-4 & n <=2) + 2*(n>=3 & n<=5)
Réponses (1)
Walter Roberson
le 1 Mai 2023
0 votes
See https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html for information on how to use Logical Indexing
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!