I am trying to plot a graph of two variables z1 and z2 versus t. but for some values of t I am getting z2 values negative in a graph. How to make these z2 values zero?

1 vue (au cours des 30 derniers jours)
I am trying to plot a graph of two variables z1 and z2 versus t. but for some values of t I am getting z2 values negative in a graph. How to make these z2 values zero for some values of t?

Réponses (2)

Star Strider
Star Strider le 6 Mar 2024
One approach —
z2 = randn(1,10)
z2 = 1×10
0.3138 -0.3598 0.9730 0.3409 0.8508 -2.6376 -1.2036 -2.4293 1.4585 -1.1442
z2(z2<0) = 0
z2 = 1×10
0.3138 0 0.9730 0.3409 0.8508 0 0 0 1.4585 0
.

John D'Errico
John D'Errico le 6 Mar 2024
Another approach...
z2 = randn(1,7)
z2 = 1×7
-1.0673 -0.3280 2.2819 -0.8316 -0.8863 -0.0035 1.4951
z2 = max(z2,0)
z2 = 1×7
0 0 2.2819 0 0 0 1.4951

Catégories

En savoir plus sur Graph and Network Algorithms 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