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