Question

Please i need final report on this program. thanks % Preparation of Data tempApril1969 = [36.5 51.5 41.5 47.5 56 50.5 54...

Please i need final report on this program. thanks

% Preparation of Data

tempApril1969 = [36.5 51.5 41.5 47.5 56 50.5 54.5 55 51 61 54 48 50 54 57.5 57.5 64 57 50.5 47.5 47 50.5 52 48 56 65.5 63.5 72 61 54.5]; % temperature data of April, 1969 (shape = 1x30)

tempApril2019 = [39.5 43.5 54 51.5 42 52.5 55 63 46.5 51 46 55.5 66.5 63 53.5 54 54 56.5 65.5 58.5 57.5 54.5 64.5 61 56 55.5 52.5 49 51.5 52.5]; % temperature data of April, 2019 (shape = 1x30)

days = 1:30; % days of month April

tempDiff = tempApril2019 - tempApril1969; % Taking difference of both datas

figure(1) % start plotting 1st figure

title('April 2019 vs. April 1969'); % setting title for the figure

bar(days,[tempApril1969',tempApril2019']); % Creating a bar chart of 2 datas simultaneously w.r.t. days in april

hold on % retain current plot when adding new plots

legend('1969','2019') % Setting legends to represent different colors of bars

xlabel('Day in April'); % Label X-axis

ylabel('Temperature') % Label Y-axis

figure(2) % start plotting second figure

plot(days,tempDiff, '--*'); % plot a line graph of temperature difference vs. days

title('Difference in Temperatures'); % setting title for the graph

xlabel('Days'); % Label X-axis

ylabel('Temperature'); % Label Y-axis

%% Calculate mean

N = length(days); % calculating length of days vector for further use

mean2019 = sum(tempApril2019)/N; % Calculating mean of temperatures of April, 2019

mean1969 = sum(tempApril1969)/N; % Calculating mean of temperatures of April, 1969

difference_of_mean = mean2019 - mean1969; % Taking difference of mean

%% Calculate standard deviation

% X2 = X * transpose(X)

% Variance(X) = ( ( X - Mean(X) )2 / No. of elements in X )

% Standard Deviation = Square root (Variance)

variance2019 = ((tempApril2019-mean2019)*(tempApril2019-mean2019)')/N; % Calculating variance of the temperature in April, 2019

variance1969 = ((tempApril1969-mean1969)*(tempApril1969-mean1969)')/N; % Calculating variance of the temperature in April, 1969

sd2019 = sqrt(variance2019); % Taking square root of variance to get standard deviation of temperature in April, 2019

sd1969 = sqrt(variance1969); % Taking square root of variance to get standard deviation of temperature in April, 1969

%% Correlation Coefficient

covariance = (tempApril2019-mean2019)*(tempApril1969-mean1969)'; % calculating covariance of temperatures in April, 1969 and April, 2019

correlationCoeff = covariance/(sd2019*sd1969); % Calculating correlation coefficient i.e. covariance_1_2 / (standard_deviation_1 * standard_deviation_2)

%% Display

% displaying the message where %f is replaced by the float value of the

% corresponding variable in the list input after the closing of quotes

msg = sprintf("The mean of temperature in 1969: %f\nThe mean of temparature in 2019: %f\nDifference of mean: %f\nStandard deviation in 1969: %f\nStandard deviation in 2019: %f\nCorrelation Coefficient: %f",mean1969,mean2019,difference_of_mean,sd1969,sd2019,correlationCoeff);

disp(msg)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

answer:

% Preparation of Data

tempApril1969 = [36.5 51.5 41.5 47.5 56 50.5 54.5 55 51 61 54 48 50 54 57.5 57.5 64 57 50.5 47.5 47 50.5 52 48 56 65.5 63.5 72 61 54.5]; % temperature data of April, 1969 (shape = 1x30)

tempApril2019 = [39.5 43.5 54 51.5 42 52.5 55 63 46.5 51 46 55.5 66.5 63 53.5 54 54 56.5 65.5 58.5 57.5 54.5 64.5 61 56 55.5 52.5 49 51.5 52.5]; % temperature data of April, 2019 (shape = 1x30)

days = 1:30; % days of month April

tempDiff = tempApril2019 - tempApril1969; % Taking difference of both datas

figure(1) % start plotting 1st figure

title('April 2019 vs. April 1969'); % setting title for the figure

bar(days,[tempApril1969',tempApril2019']); % Creating a bar chart of 2 datas simultaneously w.r.t. days in april

hold on % retain current plot when adding new plots

legend('1969','2019') % Setting legends to represent different colors of bars

xlabel('Day in April'); % Label X-axis

ylabel('Temperature') % Label Y-axis

figure(2) % start plotting second figure

plot(days,tempDiff, '--*'); % plot a line graph of temperature difference vs. days

title('Difference in Temperatures'); % setting title for the graph

xlabel('Days'); % Label X-axis

ylabel('Temperature'); % Label Y-axis

%% Calculate mean

N = length(days); % calculating length of days vector for further use

mean2019 = sum(tempApril2019)/N; % Calculating mean of temperatures of April, 2019

mean1969 = sum(tempApril1969)/N; % Calculating mean of temperatures of April, 1969

difference_of_mean = mean2019 - mean1969; % Taking difference of mean

%% Calculate standard deviation

% X2 = X * transpose(X)

% Variance(X) = ( ( X - Mean(X) )2 / No. of elements in X )

% Standard Deviation = Square root (Variance)

variance2019 = ((tempApril2019-mean2019)*(tempApril2019-mean2019)')/N; % Calculating variance of the temperature in April, 2019

variance1969 = ((tempApril1969-mean1969)*(tempApril1969-mean1969)')/N; % Calculating variance of the temperature in April, 1969

sd2019 = sqrt(variance2019); % Taking square root of variance to get standard deviation of temperature in April, 2019

sd1969 = sqrt(variance1969); % Taking square root of variance to get standard deviation of temperature in April, 1969

%% Correlation Coefficient

covariance = (tempApril2019-mean2019)*(tempApril1969-mean1969)'; % calculating covariance of temperatures in April, 1969 and April, 2019

correlationCoeff = covariance/(sd2019*sd1969); % Calculating correlation coefficient i.e. covariance_1_2 / (standard_deviation_1 * standard_deviation_2)

%% Display

% displaying the message where %f is replaced by the float value of the

% corresponding variable in the list input after the closing of quotes

msg = sprintf("The mean of temperature in 1969: %f\nThe mean of temparature in 2019: %f\nDifference of mean: %f\nStandard deviation in 1969: %f\nStandard deviation in 2019: %f\nCorrelation Coefficient: %f",mean1969,mean2019,difference_of_mean,sd1969,sd2019,correlationCoeff);

disp(msg)

Sample Run:

The mean of temperature in 1969:53.833333 The mean of tenparature in 2019: 54.20806 Difference of mean: .356667 Standard deviFigure 2 Difference in Temperatures 20 15 10 -10 -15 20 30 25 20 15 10

Add a comment
Know the answer?
Add Answer to:
Please i need final report on this program. thanks % Preparation of Data tempApril1969 = [36.5 51.5 41.5 47.5 56 50.5 54...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT