5 views

Uploaded by Karthik Reddy

b

- Statistics 2
- M 11th Class CBSE Trigonometric Functions Important Questions
- Quiz Trigonometry
- Standard Deviation and Variance
- Variance.docx
- ABSTRACT Final Document
- Semaster-1
- Outline_PPt_Week_2_Chapter+3
- MCA I Syll sem-I 2013.pdf
- hw4
- Ledoit-Wolf Shrinkage Variance Estimate
- palm_ch7
- English Class X Maths Sslllla
- CALCULADORA fx82TL.pdf
- Composite Samples
- Sky Trak
- PSY 2003 Chapter 5 Notes
- Mathcity.org
- Content
- epa subsamples.pdf

You are on page 1of 4

Instructions: Create a new directory to the Z-drive of the Computing Centres Windows system and save all files you write during the course into it. Write the code of each exercise into its own mfile as a script. Write all functions into separate files (remember: name of a function = filename!!!). Name the script files like d1e1.m (day 1, exercise 1). To be able to run your own m-files directly from the command window, you must add your directory to Matlabs path or change current working directory.

Data types

1. Structures and cell arrays a) The table below contains some measurements Measurement Filename Time Millisecond Serial Volume Length Value XML2003-01-10.xml 10.1.2003 13:13:46 474 731590.551232337962963 0.662 18.13

Store the measurements into a structure and into a cell array variable and print the variables to the command window. How do these data types differ from each other? b) How will the situation change (or will it?) if there are a lot of measurements (same fields but many values from different time instants)? Save also e.g. the following values in a sensible way to the same structure (a table?) and to a cell array. Below the table there is an example of how the variables cellArray and structure would be like if the data were stored in them. Compare the amounts of memory the variables reserve. Measurement Filename Time Millisecond Serial Volume Length Measurement Filename Time Millisecond Serial Volume Length Value XML2003-01-10.xml 10.1.2003 13:15:42 225 731590.551232337973454 0.552 12.63 Value XML2003-01-11.xml 11.1.2003 08:43:27 912 731590.551232338072548 0.264 15.16

>> cellArray cellArray = {1x3 cell} {1x3 cell} double] [1x3 double] >> structure structure = 1x3 struct array with fields: Filename Time Millisecond Serial Volume Length [1x3 double] [1x3 double] [1x3

2. Write functions for calculating the following statistical quantities. Implement each of the given formulas in its own function without using Matlabs built-in functions. You may, however, use the function sum for adding as well as the functions length, size and sqrt. As an example, apply the functions to the data in the file testData.mat. In the formulas N stands for the number of measurements. a) Average

N

x=

x

i =1

N 1 =

(x x )

i i =1

N 1

(standard deviation)

2 N 1 =

(x x )

i i =1

N 1

(variance)

Compute the average present in the formulas using the function you wrote in item a). Note that in item b) your function must return two values. c) Correlation coefficient

N

r=

( x x )( y y )

i i i =1

(x x ) ( y y )

2 i i i =1 i =1

.

2

In item c) study the correlation of the measurement first qualitatively by plotting the measurements using scatter. See the example figure below.

Interesting data 30

25

20 Second column

15

10

0.5

2.5

d) Write a script that calls all the functions that were written above and prints the results to the command window. Example output:

Measurement 1: average 0.42478, deviation 0.30788, variance 0.094792. Measurement 2: average 13.7338, deviation 5.1712, variance 26.7417. Correlation coefficient of the measurements is 0.84035.

Compare the results given by your functions to those given by Matlabs built-in functions mean, std, var and corrcoef. 3. Write the function xycorr, where you create the variables x and y. The variables are vectors of length 1000. Variable x contains normally distributed random numbers and variable y the sine wave sin(2*pi*50*t), where t is the time vector between 0 1 seconds (choose a suitable sample interval). Add to y also noise that is uniformly distributed on the interval [0, 1]. After creating the variables the function computes the correlation coefficient of variables x and y using the function created in item c) of the previous exercise. Write also a script that calls xycorr 10 times and prints the values returned by the function to the command window. Why are the values that appear to the command window different? 4. Study the forces that affect a body in the origin of a coordinate system (figure below). The magnitude and direction of each distinct force is known, and the resulting total force affecting the body (magnitude and angle) should be computed. The forces are:

F1 F2 F3 F4

F4 F2 F3 F1

Draw the forces F1 F4 affecting the body using the same color (blue) and the total force with a different color (red dashed line) to the same figure. The title of the figure must contain the magnitude and angle of the total force (cf. example figure below).

Hint: You can use the function line to draw the forces to the coordinate axes (i.e. there is no need to draw the arrowheads, a line is sufficient). For drawing and for computing the total force you need to know the x and y components of each force. In the case of the figure below the x and y components are defined as follows:

cos ( ) = sin ( ) =

x x = F cos ( ) F y y = F sin ( ) F

F x

The angles must be converted to radians before using sin or cos because in Matlab angles are given in radians. However, the angle of the total force must be given finally in degrees.

180 1 rad = .

3

Example figure:

Total force: magnitude 0.99912 N, angle 73.8697 Total force: 0.99912 N, direction: 73.8697

-1

-2

-3 -3

-2

-1

0 x

- Statistics 2Uploaded bywaleed
- M 11th Class CBSE Trigonometric Functions Important QuestionsUploaded bySudhir Kumar
- Quiz TrigonometryUploaded byMaman Firmansyah
- Standard Deviation and VarianceUploaded bystiker4
- Variance.docxUploaded bymeh
- ABSTRACT Final DocumentUploaded bySatyajeet Chauhan
- Semaster-1Uploaded byrohishaak
- Outline_PPt_Week_2_Chapter+3Uploaded byNick Chai
- MCA I Syll sem-I 2013.pdfUploaded byManjusha
- hw4Uploaded byFahad Bhatti
- Ledoit-Wolf Shrinkage Variance EstimateUploaded bySuperquant
- palm_ch7Uploaded byA Raheem Siddiqui
- English Class X Maths SsllllaUploaded byNichole Guerrero
- CALCULADORA fx82TL.pdfUploaded bylucio1911955
- Composite SamplesUploaded byMas Bro
- Sky TrakUploaded bymariana
- PSY 2003 Chapter 5 NotesUploaded byGabe Marquez
- Mathcity.orgUploaded byyasir wyne
- ContentUploaded byRaizen Sangalang
- epa subsamples.pdfUploaded byRaul Santiago Ramos
- Effect of Ultrasonic Transducer Beam Profile on Accuracy of Discontinuity Detection During ScanningUploaded bybrostolo
- Collateral Value Risk-commodity Linked ExposuresUploaded byKrishnan Chari
- STAUploaded byshajib_sust
- Ömer Nezi̇h Gerek Presentation1Uploaded byangarali26
- A Continuous Approach to Considering Uncertainty in Facility DesignUploaded bySailesh Kondraganti
- Summer Review Packet 8Uploaded byteachopensource
- Accurate Object LocalizationUploaded byAnjar Triyoko
- Add Math p2 Trial Spm Zon b 2011Uploaded bySalmizam Izam
- @@@@@@@@@@@Pie Charts and Standard Deviation.pptx@@@@@@@@@Uploaded byFirstlady Gentles
- Morris Freedman et al- Effects of Frontal Lobe Lesions on Intentionality and Random Physical PhenomenaUploaded bySonyRed

- IFR Chart SymbolsUploaded byhoushang5
- Immersive Calibration PRO User GuideUploaded byKarthik Reddy
- Tps 79301Uploaded byKarthik Reddy
- Tps 79301Uploaded byKarthik Reddy
- 2N7002Uploaded byCale McCollough
- Auth (1)Uploaded byKarthik Reddy
- d2o-o10Uploaded byKarthik Reddy
- d2o-o10Uploaded byKarthik Reddy
- ifr_introUploaded byKarthik Reddy
- DGCA CPL ApplicationUploaded byCyril Mathew Roy
- aac3_2001Uploaded byKarthik Reddy
- 00000___3aa692a64245260f26fcce123c36b80cUploaded byKarthik Reddy
- 00000___3aa692a64245260f26fcce123c36b80cUploaded byKarthik Reddy
- D2O-O6 (Draft Sept 2011)Uploaded byKarthik Reddy
- Indian Aircraft Rules 1937 Part11Uploaded byvikash_kumar_thakur
- Exercises 5Uploaded byKarthik Reddy
- IntercomUploaded byapi-3750426
- Problems 2Uploaded byKarthik Reddy
- CA28Uploaded byKarthik Reddy
- mini_pmdc_motorsUploaded byKarthik Reddy
- Exercises 4Uploaded byKarthik Reddy
- 45483520 Check List COPUploaded byKarthik Reddy
- Tough ProblemsUploaded byKarthik Reddy
- Raspberry PiUploaded byrob143393
- Combination of Simple + Tough ProblemsUploaded byKarthik Reddy
- a16weUploaded byKarthik Reddy
- hexcrawler_v3.1Uploaded byKarthik Reddy
- Problems 3Uploaded byKarthik Reddy
- Simple Problems for PracticeUploaded byKarthik Reddy

- bab 4 bse bhs inggris kls 8 by gieUploaded byginanjar
- Some Protocols Used in GPRSUploaded byDhruv Seth
- The Characteristics of Romantic PoetryUploaded byTANBIR RAHAMAN
- Nggsic PromoUploaded byAshikin Shuhaimi
- Witness 2006Uploaded byVC Chua Yee Leong
- 241119-100-DS3_DSheet-Flatpack2-Rectifier_48-3kW_v2Uploaded byRaul Guevara Ascan
- Persian SpeakingUploaded bymeczupca
- English WordsUploaded bychandrashekhar
- SQL and Modeling WordUploaded byKent Mabait
- SAP Workflow TcodesUploaded bySiva Krishna
- Lectures on Sectional-Anosov Fl - S. Batista, Carlos MoralesUploaded byjesusdark44
- BalUploaded byManisha Nisha
- PrepUploaded byFahd Ali Shifa
- Code Rage 2.0Uploaded byxelipe
- CodesUploaded byherbert_obed
- MY LESSON PLAN UNIT 9.docxUploaded bynur atikah zakaria
- Implementing Siebel eBusiness ApplicationsUploaded byhendyoldboy
- 48lc16m16a2Uploaded byvsc2012
- life history interview of xxxxUploaded byapi-241434187
- cassia maguire resumeUploaded byapi-389587075
- DICKIE, George - Defining ArtUploaded byCássio
- VargaUploaded byShiva Shankar
- Whats New Java 8Uploaded byshadowtoasta
- RahnerUploaded byKlaus Hoffmann
- Laravel 4 TestingUploaded byAnte Lutek
- Opencv TutorialUploaded byHimanshu Vimal
- Persian Lessons in RomanizationUploaded byФранк Ким
- Website ReportBKUploaded bycirruscasino
- Course ListingUploaded byavram.lau4038
- [Winnicott] Through Paediatrics to PsychoanalysisUploaded byulysse