I need help, I don't even know where to start

3 views (last 30 days)
Kyle
Kyle on 21 Mar 2013
Heres the problem:
Before you start writing your program: Read all of these instructions carefully. Using previous assignments as a guide determine the following for this problem. 1. Problem Constants: (with units, as needed) 2. Problem Inputs: (with units, as needed) 3. Problem Outputs: (with units, as needed) 4. Other variables: (with units, as needed) 5. Equations 6. Algorithm: Copy and paste your algorithm as comments in your program. Include 1-6 from above in the comments at the top of your Lab07.m file. Program: Lab07.m Edwin Hubble used the Mount Wilson Observatory telescopes to measure features of nebulae outside the Milky Way. He found that there is a relationship between a nebula’s distance from earth and the velocity with which it was traveling from the earth. Hubble’s initial data on 24 nebula is presented in Table 1 in the problem scenario. The relationship between distance and velocity led scientists to propose that the universe came into being with a Big Bang, a long time ago. If material scattered from the point of the Big Bang traveling at a constant velocity, the distance traveled can be determined. Using Hubble’s data, find the linear equation that estimates the relationship between the velocity and distance readings. Display the data in a table and graph. General Instructions:  Insert comments at the top and throughout each file o Include the follow comments at the beginning of this (and ALL) files. your name Grade of zero for files with incorrect author name assignment number Zero points for comments if no collaboration statement date you completed the assignment statement(s) about collaboration a short narrative about what the file does o Use the algorithm as comments throughout each file. o Add section headers. See Standards for Documentation of MATLAB programs on Resources page on Canvas.  Variables: o Use ALL CAPS for constants variable names. o Start other variables with lower case. o Use descriptive variable names. o Use variables for data values. Note: zero(0), one (1), and column index numbers are allowed.  Code clarity: o Indent blocks as needed. In editor, select ALL, right-click, Smart Indent in the pop-up menu. o Divide you solution program code into sections as noted in the algorithm. o Use section comments as well as the algorithm step comments. o Use blank lines as needed to group statements.  Data file: o Check for good open. Display system message and end program there is a problem. o Use fscanf() to read one row at a time. o Read Hubble’s data from hubbleData.txt. Read until the end-of-file is found o You know that there are five columns, but you will need to count the rows of data read o There are five columns of data in the data file. You will read all but only use the velocity and distance in the program computations. Compare hubbleData.txt with the table in the scenario for the column content. o Velocity will be the independent variable(x) variable and distance dependent variable(y). o You know that there are five columns, but you will need a row counter for the row index as the data is read.  Computation o Use the given formula to compute the slope and intercept for the given data. o Create the regression equation that estimates the relationship between the velocity and distance readings. COMP1200M – Spring 2013 – Lab07 – p. 2 of 2  Output o NO extra output, i.e. use semicolon as needed and use “clc, clear all” to remove previous output. o Label output using the fprintf()function.  Format the output decimal places as shown in the sample below.  Include units, if applicable. o Columns of numbers right-aligned. o Print the velocities and distances in a two columns with a title and column headings o Print slope and y-intercept in the form of a linear equation. o Display the data in a scatter plot and line of the graph a linear equation Use the code below to draw a scatter plot for the data pairs and draw a line of the linear equation o Replace velocity column and distance column with matrix columns where you saved velocity and distance. o “hold on” allows the line plot to be drawn in the same figure as the scatter. o Create a vector xVelocity starting with minimum value of Hubble’s velocity and ending with the maximum value of Hubble’s velocity. o Compute the values for yDistance using the linear equation that you created. % create a scatter plot of the velocity and distance data % plot the line created by your linear equation scatter( velocity column, distance column ) hold on % allows both graphs in the same figure xVelocity = _____________________________; yDistance = _____________________________; plot(xVelocity,yDistance) Sample Input/Output: NEBULA INPUT DATA VELOCITY DISTANCE km/sec 106 parsecs 170 0.032 290 0.034 -130 0.214 . . . 500 2.000 850 2.000 800 2.000 1090 2.000 LINEAR EQUATION: distance = 0.0014 * velocity + 0.399 Submit via Canvas: Lab07.m MATLAB script file New commands: feof() fscanf() one row at a time scatter(), plot() You know number of columns = 5. …more indexing and colon notation. Regression Definition: A regression is a statistical analysis assessing the association between two variables. It is used to find the relationship between two variables. Regression Formula: Regression Equation y = mx + b Slope (m)= n (Σxy)− (Σx)(Σy)/ n(Σx^2)− (Σx)^2 Intercept (b)= (Σy)(Σx^2)−(Σx)(Σxy)/ n(Σx^2)− (Σx)^2 n is the number of x,y pairs
Additional information:
Edwin Hubble used the Mount Wilson Observatory telescopes to measure features of nebulae outside the Milky Way. He found that there is a relationship between a nebula’s distance from earth and the velocity with which it was traveling from the earth. Hubble’s initial data on 24 nebula is presented in Table 1 below and stored in hubbleData.txt (Hubble, 1929). The relationship between distance and velocity led scientists to propose that the universe came into being with a Big Bang, a long time ago. If material scattered from the point of the Big Bang traveling at a constant velocity, the distance traveled can be determined. Table 1. Nebulae Whose Distances Have Been Estimated From Stars Involved Or From Mean Luminosities In A Cluster
  • object ms r v mt Mt S. Mag.1 .. 0.032 + 170 1.5 -16.0 L. Mag.2 .. 0.034 + 290 0.5 17.2 NGC 6822 .. 0.214 - 130 9.0 12.7 NGC 598 .. 0.263 - 70 7.0 15.1 NGC 221 .. 0.275 - 185 8.8 13.4 NGC 224 .. 0.275 - 220 5.0 17.2 NGC 5457 17.0 0.45 + 200 9.9 13.3 NGC 4736 17.3 0.5 + 290 8.4 15.1 NGC 5194 17.3 0.5 + 270 7.4 16.1 NGC 4449 17.8 0.63 + 200 9.5 14.5 NGC 4214 18.3 0.8 + 300 11.3 13.2 NGC 3031 18.5 0.9 - 30 8.3 16.4 NGC 3627 18.5 0.9 + 650 9.1 15.7 NGC 4826 18.5 0.9 + 150 9.0 15.7 NGC 5236 18.5 0.9 + 500 10.4 14.4 NGC 1068 18.7 1.0 + 920 9.1 15.9 NGC 5055 19.0 1.1 + 450 9.6 15.6 NGC 7331 19.0 1.1 + 500 10.4 14.8 NGC 4258 19.5 1.4 + 500 8.7 17.0 NGC 4151 20.0 1.7 + 960 12.0 14.2 NGC 4382 .. 2.0 + 500 10.0 16.5 NGC 4472 .. 2.0 + 850 8.8 17.7 NGC 4486 .. 2.0 + 800 9.7 16.8 NGC 4649 .. 2.0 +1090 9.5 17.0 ------ Mean -15.5
ms - photographic magnitude of brightest stars involved r - distance in units of 106 parsecs. The first two are Shapley's values. v - measured velocities in km/sec N. G. C. 6822, 221, 224 and 5457 are recent determinations by Humason. mt - Holetschek's visual magnitude as corrected by Hopmann. The first three objects were not measured by Holetschek, and the values of mt represent estimates by the author based upon such data as are available. Mt - total visual absolute magnitude computed from mt and r.
.....please help. I dont know where to even start or what to do
  1 Comment
Cedric
Cedric on 21 Mar 2013
You should start with small steps and not try to imagine the full solution in one shot. For example, try to see if you are able to read a text file with the data that you need to process. For that read the doc of relevant functions and experiment
>> doc fopen
>> doc fscanf
>> doc feof
>> doc fclose
you will find examples in the doc, that you can experiment with, until you get comfortable with the material. It will be easy at this point to read your data file and then you'll think about the next small step.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 21 Mar 2013
Can you work with anthony on this homework?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!