Illustration of plot function, C/C++ Programming

Illustration of Plot function:

To be more common, the script could prompt the user for the time and temperature, instead of just assigning the values. Then, the axis function could be used depending on whatever the values of x and y is, for illustration,

axis([x-2 x+2 y-10 y+10])

In order to plot more than one point, x and y vectors are formed to store the values of the (x,y) points. For illustration, to plot the points

(1,1)

(2,5)

(3,3)

(4,9)

(5,11)

(6,8)

At first an x vector is formed which has the x values (as they range from 1 to 6 in steps of 1, the colon operator can also be used) and then a y vector is formed with the y values. This will generate (in the Command Window) x and y vectors and then plot them as shown in figure:

2402_Illustration of Plot function.png

 

>> x = 1:6;

>> y = [1 5 3 9 11 8];

>> plot(x,y)

Note that the points are plotted with straight lines drawn in between. The axes are also set up according to the data; for illustration, the x values ranges from 1 to 6 and the y values from 1 to 11, and hence, that is how the axes are set up.

Also, note that in this situation the x values are the indices of the y vector (the y vector has 6 values in it, therefore the indices iterate from 1 to 6). Whenever this is the situation, it is not essential to generate the x vector. For illustration,

>> plot(y)

will plot exactly the similar figure without using an x vector.

Posted Date: 10/18/2012 6:52:31 AM | Location : United States







Related Discussions:- Illustration of plot function, Assignment Help, Ask Question on Illustration of plot function, Get Answer, Expert's Help, Illustration of plot function Discussions

Write discussion on Illustration of plot function
Your posts are moderated
Related Questions
Write a program to process bank accounts. Create a base class named Account and two derived classes named Savings and Checking. In the base class, use an int AccountNum and a dou

Virtual Base Classes This ambiguity can be resolved if the class derived have only one copy of the class base. This can be done by making the base class a virtual class. This k


a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between tw


How does placing some code lines between comment symbols help in debugging the code? - Placing comment symbols /* */ around a code separates some code that coder believes might

Explain the Bit Wise Operators? C language has distinction of supporting special operators recognized as bit wise operators for manipulation of data at bit level. These operato

1 Aims The main purpose of the assignment is to let you practice the following programming techniques: perform operations on pointers to basic and more complex types;

Draw a flowchart for a program that allows the user to enter 20 names along with their ages and their Social Security Numbers in three parallel arrays. Programs shou

(c) A static member function can access static member data only, static member functions and functions and data outside the class. A static member function may be called, even whil