Info
This question is closed. Reopen it to edit or answer.
can you help me?
1 view (last 30 days)
Show older comments
a) Import Data
This data is from https://www.data.gov/
Please go to the website first to look at all the possible Comma Separated Value (CSV) data that you can import. For simplicity, don’t search for the file on this site. Just get a feel for the data you can download. You can use this sight for your projects if desired.
Go to Canvas for our class (ECE105), and download the data file under week 10. The file is about 15Mb, and this file should end up in your download folder:
“Heart_Disease_Mortality_Data_Among_US_Adults__35___by_State_Territory_and_County (1).csv”
Open Matlab, and click on import data. It will show your files. Find your download folder, find the heart disease file, make sure it’s highlighted by clicking on it, and click on open in the lower right.
Matlab should open the file.
Under “Range” in the menu bar of your import window, change the range to H2:H59077. Then click just outside of the range box, and Matlab should highlight just that one column. Column H should be highlighted, and you’re about to import a 50976 row x 1 column matrix of numbers.
In the “Output Type” box right next to the “Range “ box, use the drop down menu and select “numeric matrix”. That gives you a matrix rather than the default table of numbers. In the box next to output type, for cells with data that are unimportable replace “NaN” (which is the default) to 0.0 (number 0). If you don’t do this your mean value will come out to NaN.
Now you should be set, and click on the green check mark in the upper right. It will take about 10 to 20 seconds to import the data depending on your computer.
Close the import window, and look at your workspace. You should see the matrix.
I suggest changing the name because it’s too much to type.
In the command window type:
A= HeartDiseaseMortalityDataAmongUSAdults35byStateTerritoryandCoun;
Don’t forget the semicolon at the end or Matlab will put all those values in the command window. If it does, just use a clc command.
Now save your workspace. Click on “Save Workspace” in the menu bar, enter “Heart_Disease” as the file name, and click save. Check your MATLAB folder to make sure “Heart_Disease.mat” is in there.
b) Calculate maximum, mean and median
Now that you have the data, generate a script that calculates
Maximum, minimum, mean, and median of A. Minimum should be 0.
c) Use “fprintf “ command to come up with this:
“For 100,000 heart patients in the U.S., the max death rate by county is 6350.700000
the mean death rate is 199.293282
and the median death rate is 187.800000”
example:
fprintf('For 100,000 heart patients in the U.S., the max death rate by county is %f \n', a)
where “a” has been assigned to the maximum value
remember %f is the number you want and /n is a line feed
can you help me?
0 Comments
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!