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 次查看(过去 30 天)
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?

回答(2 个)

Star Strider
Star Strider 2024-3-6
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 2024-3-6
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

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by