Plotting file data, MATLAB in Engineering

Assignment Help:

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


Related Discussions:- Plotting file data

Preallocating a vector, Preallocating a Vector: There are necessarily ...

Preallocating a Vector: There are necessarily two programming techniques that can be used to simulate the cumsum function. One technique is to begin with an empty vector and c

Symbolic variables and expressions, Symbolic Variables and expressions: ...

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

Interpolation and extrapolation, Interpolation and extrapolation: In m...

Interpolation and extrapolation: In most cases, it is desired to estimate values other than at the sampled data points. For illustration, we may want to estimate what the temp

Function used in binary search, Function used in binary search: The fu...

Function used in binary search: The function below implements this binary search algorithm. It receives two arguments: the sorted vector and a key (on the other hand, the func

Example exit modular program, Example Exit modular program: In the ill...

Example Exit modular program: In the illustration below, the user  Chose the Limit; -   Whenever prompted for n, entered the two invalid values before finally ente

Example of plotting from a function, Example of Plotting from a Function: ...

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

Illustration of passing arguments to functions, Illustration of Passing arg...

Illustration of Passing arguments to functions: Here is an illustration of calling this function: >> printrand() The random # is 0.94 As nothing is passed to

Variable scope, Variable Scope: The scope of any of variable is the wo...

Variable Scope: The scope of any of variable is the workspace in which it is valid. The workspace generated in the Command Window is known as the base workspace. As we know

Illustration of subfunctions, Illustration of Subfunctions: This is an...

Illustration of Subfunctions: This is an illustration of running this program: >> rectarea Please enter the length: 6 Please enter the width: 3 For a rectan

Creating a cell array - assign values to array, Creating a cell array: ...

Creating a cell array: The other method of creating a cell array is easy to assign values to particular array elements and build it up element by element. Though, as explained

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd