Project Calculus (Nov 26 2023)
Project Calculus (Nov 26 2023)
In the realm of business analytics, the ability to foresee future sales trends is
invaluable. By leveraging the time-stamped sales records dataset, our primary goal is
to construct a predictive model that can reliably estimate forthcoming product sales.
A thorough exploration of the time-stamped sales records dataset will be conducted
to understand the distribution of sales over time. line plots, and histograms, will be
utilized to represent sales data. Linear regression will be used as a forecasting
technique. Through derivative analysis, the rate of change of sales over time will be
investigated to discern acceleration or deceleration in sales. Integration of derivative
analysis results with the selected predictive model will be performed. A step-by-step
analytical solution will be provided to outline the chosen predictive model and
derivative analysis.
1
Analytical Solution:
2
3
4
Flow Chart
START
Select your
desired data
Construct a graph on
excel and use linear
trendline regression
END
5
Graphs of Linear regression:
6
MATLAB CODE
% Provided data
year = [1980, 1985, 1990, 1995, 2000, 2005];
sales = [205000, 240000, 235000, 255000, 260000, 262000];
% Part 0: Display programming team information
disp('Programming Team: Maryam Iftikhar (23I 3046), Ayesha Gohar (23I 3030)');
% Part 1: User input for the year
year_to_predict = input('Enter the year for sales prediction (e.g., 2025): ');
% Part 2: Display message and wait for key press to continue
disp('Press any key to continue...');
pause;
% Part 3: Linear regression model
mdl = fitlm(year, sales);
% Part 4: Predict sales for the input year
predicted_sales = predict(mdl, year_to_predict);
disp(['Predicted sales for ', num2str(year_to_predict), ': ', num2str(predicted_sales)]);
% Part 5: Display results of part 2 (Rate of change of sales over time)
disp('Results of Part 2:');
% Calculate the rate of change of sales over time
sales_rate_of_change = diff(sales) ./ diff(year);
disp('Rate of change of sales over time:');
disp(sales_rate_of_change);
% Part 6: Display message and wait for key press to continue
disp('Press any key to continue...');
pause;
% Part 7: Display results of part 3 (Analysis of sales over time)
disp('Results of Part 3:');
% You can perform additional analysis on the sales data over time if needed.
% Part 8: Ask user if they want to continue or terminate the program
user_input = input('Do you want to continue? (Enter "yes" to continue, "no" to terminate): ', 's');
if strcmpi(user_input, 'no')
7
disp('Program terminated.');
else
% If the user wants to continue, you can add additional tasks or analyses here.
disp('Continuing...');
end
Explanation:
In the MATLAB code, data is provided of years and sales for 1980 till 2010. Then
name of group members and ids are displayed. A message is displayed which asks
the user to press any key to continue and pause function is used. Then function is
written to predict sales based on provided year. Then another function is written to
calculate rate of change of sales over time. Then user is asked whether he wants to
continue or not. If user enters yes the continuing message is displayed else if user
enters no then the program is ended.
MATLAB SOLUTION
>>
Programming Team: Maryam Iftikhar (23I 3046), Ayesha Gohar (23i3030)
Enter the year for sales prediction (e.g., 2025):
2025
Press any key to continue...
Predicted sales for 2025: 310619.0476
Results of Part 2:
Rate of change of sales over time:
7000 -1000 4000 1000 400
Press any key to continue...
Results of Part 3:
Do you want to continue? (Enter "yes" to continue, "no" to terminate):
yes
Continuing...
>>
Explanation of commands:
clc: This command is used to clear all the text from the Command Window.
clear all: This command is used to clear all variables from the current workspace.
8
syms: This command creates symbolic variables for storing different values.
pause: This command stops the execution until some key is pressed.
fprintf: This command prints a message in the command window.
disp: This command displays the variable or the text in command window.
solve: This command find the value of variable in an equation.
subs: This command is used to substitute some value in an equation.
vpa: This command gave the precise arithmetic value.
round: This command is used to round off the decimal value.
input: This command take the input value and store it in variable.
Program Specification:
Contribution:
We have done this project while understanding each command and logic individually
and then implementing those methods to make a single MATLAB project. Maryam
Iftikhar mostly contributed to solving the MATLAB part, while Ayesha Gohar
handled solution solving.
Conclusion:
The MATLAB code predicts the sales according to the provided data. This program
is a quicker way to find solutions to the required problem. Doing it by hand is time
consuming. Using Matlab we can quickly solve the big problems that save us a lot of
time. The calculations done using matlab are more accurate and precise.