Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
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?

Respuestas (2)

Star Strider
Star Strider el 6 de Mzo. de 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 el 6 de Mzo. de 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

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by