xproject1pdf ? ? Dr pt oxInc us1 1 https//wwwdropboxcom/sh chfop 7 AABP31zcORO h
ID: 3708178 • Letter: X
Question
xproject1pdf ? ? Dr pt oxInc us1 1 https//wwwdropboxcom/sh chfop 7 AABP31zcORO ht K 4FMw E9a? I: & review:project11.pdf kr7p ? projecti 1.pdf In this assignment you're going to write a MATLAB function (m file) to analyze crime data on UIC's East campus. Given the # of crimes each month for 3 different years, your program will analyze this data to produce 'two* outputs: (1) a figure with line graphs of each year, and (2) a summary of the trend for each month. For example, suppose we are analyzing the crime data for 2012, 2013, and 2014. Here's the figure your program should produce (notice the legend, title, labels on each axis, and months along X axis): Fle Edit View Insert Tools Desktop Window Help Crimes on UIC East Campus 70 2012.txt 2013.tt 2014.txt 60 50 40 10 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Now Dec MonthsExplanation / Answer
First copy paste all the text files (2011.txt, 2012.txt and 2013.txt) to the MATLAB folder where the Matlab script file (AnalyzeCrimesAtUIC.m) is located. Copy paste the code below and run. It should work.If you have any questions, ask as a comment. I will reply to it.
The code:
addpath(pwd)
function AnalyzeCrimesAtUIC(file1,file2,file3)
fileID = fopen(file1,'r');%this opens the first file
formatSpec = '%f';
file1 = fscanf(fileID,formatSpec)
fileID = fopen(file2,'r');
formatSpec = '%f';
file2 = fscanf(fileID,formatSpec)
fileID = fopen(file3,'r');
formatSpec = '%f';
file3 = fscanf(fileID,formatSpec)
months = ['Jan';'Feb';'Mar';'Apr';'May';'Jun';'Jul';...
'Aug';'Sep';'Oct';'Nov';'Dec';]
plot(file1,'color','r')
set(gca,'xtick',1:12,...
'xticklabel',{'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct',...
'Nov','Dec'})
xlabel('months') % x-axis label
ylabel('Num of Crimes')
title('2011')
hold on
plot(file2,'color','g')
set(gca,'xtick',1:12,...
'xticklabel',{'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct',...
'Nov','Dec'})
xlabel('months') % x-axis label
ylabel('Num of Crimes')
title('2011')
plot(file3,'color','g')
set(gca,'xtick',1:12,...
'xticklabel',{'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct',...
'Nov','Dec'})
legend('2011.txt','2012.txt','2013.txt')
xlabel('months') % x-axis label
ylabel('Num of Crimes')
title('2011')
hold off
end
AnalyzeCrimesAtUIC('2011.txt','2012.txt','2013.txt')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.