How to draw piecewise function in MATLAB
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)