Hints for plotting the data
in Matlab
Hints for plotting the data in Microsoft Excel
>load name.txt
This command plots column 3 on the x-axis and column 5 on the y axis.If you need to rescale some particular column and then plot the data, you can use the same command with modifications. For example, if you need to multiply column 3 by (pi/180), then you can use the command >plot(name(:,3)*(pi/180),name(:,5))
>axis([x1 x2 y1 y2])
where
x1 is the lower limit on the x axis.
x2 is the upper limit on the x axis.
y1 is the lower limit on the y axis.
y2 is the lower limit on the y axis.
a) Open the data file for data editing.
b) Remove the portion which you think is having a non-linear relationship between the variables that have to be plotted.
c)Save the file as name2.txt
d)load the data file name2.txt using
>load name2.txt
d)Use the command
>plot(name(:,3),name(:,5))
to check if the plot shows a linear relationship between the values.
e)Now use the following commands to find the slope of the plot.
>X=name2( :,3)
>Y=name2(:,5)
>[K C]=polyfit(X,Y,1)
After the last command you see two numbers, lets say
K C
The last command assumes a linear relationship between X and Y values i.e. Y=KX+C. and then gives the value of K and C.
a) When you click on the open tab, Excel automatically starts the Text Import Wizard. Click the Delimited option in the file type. In Start import at row make the value 1 and click Windows ANSI in the file origin window. (the last 2 are default options most of the times). Click on the Next tab.
b) In the Delimiters option, check tab and Space options. In Text qualifier box "(double inverted commas) should be chosen as the option. Click the Next tab.
c) Click Finish tab.
5. Now (lets say) to plot column 3 vs. column 4.
a) Click on the C tab. This highlights the third column. Now press the Control key on the keyboard and click on the D tab. Now you have column 3 and 4 highlighted.
b) Now open the Insert tab on the menu and click on the Chart. This opens the Chart Wizard.
c) In the Standard Type menu, click on the XY(Scatter).In the Chart sub-type click on any option except which shows only the points. Click the Next tab.
d) The Chart Wizard now shows the Data and Series tab. Click the Series tab and fill in the name as Plot of 3 vs. 4 .Click the Next tab.
e)In the Chart Options menu, you can label the axes, add gridlines etc. In the Legend menu you can specify if you want to see legend on the chart by checking/unchecking the Show legend option. Click the Finish tab.
6.To find the slope of the line in the linear region.
a) Remove the portion which you think has a non-linear relationship between the variables that have to be plotted. Plot the new data.
b) Click on the plot to highlight it.
c) Go to the Chart menu and click on the Add Trendline option. This opens the Add Trendline window.
d) In the Type menu choose Linear option.
e) Click the Options tab in the window .Check the Display equation on chart option and click OK. This plots a linear fit and gives the slope and the offset of the fit.
Note: Sometimes, Microsoft Excel decides on the format of the values on axis and the limits of the axis automatically. This may lead to confusion and poor graphs. For e.g. it can write numbers (0, 25, 50) as (0.00e00, 2.50e01, 5.00e01). But you can choose your own limits and format of values. To do this, click on the X or the Y axis of the chart. This opens the Format Axis window. You can change the limits of the axis by going to Scale menu and filling in your own limits. Go to the Number menu and choose the format of values which you like to be displayed on the graph.