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?

2 visualizzazioni (ultimi 30 giorni)
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?

Risposte (2)

Star Strider
Star Strider il 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 il 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

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by