Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to draw piecewise function in MATLAB

Shulou Source: shulou.com Published: 2022-06-01 06:29:41 09月22日 Update

Editor to share with you how to draw segmented functions in MATLAB, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Recently I saw this:

A piecewise function, so take the time to write an article about the technique of drawing piecewise functions

.

When we first started to learn programming, we all used the: if-else structure. But the vectorization operation in MATLAB gives us another way of thinking (look directly at the code):

T = 0 / 0 / 0 / 0 / 0.001 / 1 / 1

F_c3_2 = (t > 0.5). * cos (80*pi.*t-15*pi) + (t 0.5: will produce a logical vector. The piece greater than 0.5 is 1, and the part less than or equal to 0.5 is 0, so:

* cos (80*pi.*t-15*pi)

The segment with t greater than 0.5 is completed, and the part with t less than or equal to 0.5 is 0.

By the same token:

(t)

Tags: Functions parts articles code content results consistent not so original text vectors most that is ideas skills time more knowledge structure industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info OPPO Reno Shulou Technology MySQL