Here we discuss an introduction to Matlab Plot Colors, along with color code table and respective examples. Because you don't explicitly have x values and you just want the y values. xp are the points you want to evaluate the function at. interp1 can be called in the following way (using linear interpolation): out interp1 (x, y, xp, 'linear') x are the x values and y are the y values for the control points. There could be instances when we have to plot multiple functions in a single plot, in such cases, colors become very handy to differentiate between different functions. As what Raab70 said, you can use interp1. MATLAB can be used to plot our data for visualizing and intuitively understanding it. Observe in the output that we have obtained a scatter plot of red color, as passed by us in the input argument. Syntax of using MATLAB Linspace to generate linearly spaced vector y linspace(x1,x2) y linspace(x1,x2,n) An example of using Linspace values linspace(1, 10, 5) Output: values 1.0000 3.2500 5.5000 7.7500 10. Observe in the code that we have passed pre-defined color code for red as an argument (Please refer to the table at the end of the article for pre-defined color codes) Observe in the code that we have passed pre-defined color code for green as an argument (Please refer to the table at the end of the article for pre-defined color codes)įor this example, we will scatter plot of red color Let us first define an array to create a Bar plot: How to Set the Color of Bar Plots?įor this example, we will create a bar plot with bars of green color. You were actually very close to getting this right. 100 - for that you would use linspace(0,100,101) since there are 101 elements in 0:100. Observe in the code that we have passed pre-defined color codes as arguments (Please refer to the table at the end of the article for pre-defined color codes) How our input and output will look like in MATLAB console?Įxplanation: As we can see in our output, we have got our functions in the colors as passed by us in the input. xlinspace(0,100,100) First comment: this will not produce 0 1 2. Note: For this example, we will be creating our functions in following colors: 1 st function in Green, 2 nd function in Blue and 3 rd function in Yellow] example: plot(X, a, ‘g’, X, b, ‘b’, X, c, ‘y’)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |