Plotting file data, MATLAB in Engineering

Plotting File data:

It is frequently essential to read data from a file and plot it. Generally, this entails knowing the format of the file. For illustration, let us suppose that a company has two divisions, called A &B. The file 'ab06.dat' has 4 lines in it (we will suppose this), with the sales figures in millions for the two divisions for each quarter of the year 2006. For illustration, the file may appear like this (the format will be precisely like this):

A5.2B6.4

A3.2B5.5

A4.4B4.3

A4.5B2.2

 

The script below reads the data and plots in one Figure Window the data as the bar charts. The script prints an error message when the file open is not successful or when the file close was unsuccessful. The axis command is used to force the x-axis to range from 0 to 3 and the y-axis from 0 to 8 that will result in the axes shown here. The numbers 1 and 2 would display on the x-axis instead of the division labels A and B by default. The set function modifies the XTickLabel property to use the strings in the cell array as labels on the tick marks on the

x-axis; and gca returns the handle to the axes in the present figure (it stands for "get present axes").

609_Plotting File data.png

Running this generates the subplot as shown in figure.

1154_Plotting File data1.png

Posted Date: 10/22/2012 2:23:20 AM | Location : United States







Related Discussions:- Plotting file data, Assignment Help, Ask Question on Plotting file data, Get Answer, Expert's Help, Plotting file data Discussions

Write discussion on Plotting file data
Your posts are moderated
Related Questions
Illustration of anonymous functions: Dissimilar functions stored in the M-files, when no argument is passed to an anonymous function, the parentheses should still be in the fu

Symbolic Variables and expressions: The MATLAB has a type known as sym for the symbolic variables and expressions; these work with strings. The illustration, to generate a sym

Use polyval to evaluate the derivative at xder. This will be the % slope of the tangent line, "a" (general form of a line: y = ax + b). % 4. Calculate the intercept, b, of t

Indexing into Vectors of structures: Frequently, when the data structure is a vector of structures, it is essential to iterate through the vector in order by various fields. F

Illustration of Variable scope: Running this function does not add any of variables to the workspace, as elaborated: >> clear >> who >> disp(mysum([5 9 1]))

Illustration of Image processing: This displays that there are 64 rows, or in another word, 64 colors, in this specific colormap. It also displays that the first five colors a

Scaling:   change a row by multiplying it by a non-zero scalar sri →  ri For illustration, for the matrix:

Example of Plotting from a Function: For illustration, the function can be called as shown below:      >> y = [1:2:9].^3      y =     1  27  125  343  729

Related Structure Functions: There are many functions which can be used with structures in a MATLAB. The function isstruct will return 1 for logical true when the variable arg

Print from the structure: To print from the structure, a disp function will show either the whole structure or a field. >> disp(package) item_no: 123 cost: 19.99