how to use <= or >= (greater than or equal to) in 'for statements '?

1 vue (au cours des 30 derniers jours)
Pramod Sapkota
Pramod Sapkota le 28 Fév 2020
Modifié(e) : Matt J le 28 Fév 2020
I want to use these equations in matlab. But it says parse error and might me invalid in matlab.
P = 0.73*x-103.43; for (x>= 141.9)
and
P = 0.06*x-8.04; for (x< 141.9)

Réponse acceptée

Matt J
Matt J le 28 Fév 2020
Modifié(e) : Matt J le 28 Fév 2020
P=nan(size(x));
region=(x>=141.9);
P(region) = 0.73*x( region )-103.43;
P(~region) = 0.06*x( ~region )-8.04;

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by