Effacer les filtres
Effacer les filtres

Creating a piecewise function using for and if

2 vues (au cours des 30 derniers jours)
Noah
Noah le 19 Sep 2022
Réponse apportée : Chunru le 20 Sep 2022
For an assignment, I need to create a piecewise graph using only for and if statements, but I have two equations, 15 + 2*(x-1), x>=2, and 15 if x is between 0 and 2 for a data set of 0:0.1:5 I am not sure how I would construct this.

Réponse acceptée

Chunru
Chunru le 20 Sep 2022
% Here are some hints for your try
% data set of 0:0.1:5
x = 0:0.1:5;
% for loops over x
for i=1:length(x)
% if statements
if x(i) satisfies certain conditions
do whatso ever
else
do something else
end
end

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by