I want to draw a function f given as 2 vectors: x and y, so y=f(x).
I use plot(x,y), but now I need it be blue above 0 and red under so it look like this:

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you plot a vector in matlab, any segment of that vector that is filled with NaNs will not be plotted. So one trick to accomplish your goal is to plot a second line on top of the original one with the relevant segments removed using Nans. For example,