Hi @Kyle,
After reviewing your comments, let me break down the key components and formulate a MATLAB code that incorporates your requirements.
Present Worth Analysis: This method helps evaluate the profitability of different projects by comparing their net present values (NPV).
Value of Saving a Human Life: You have a range for this value ($100,000 to $500,000).
Value of Preventing Injury: Defined as a function of the saving life value.
Data Structure: You have multiple projects, each with specific metrics on lives saved and injuries prevented.
For each project, compute the total monetary value based on lives saved and injuries prevented and use MATLAB to visualize the findings. Here is an updated MATLAB code that calculates the total present worth based on your criteria:
% Define constants savingLifeRange = [100000, 500000]; % Range for saving a human life injuryFactor = [1/4, -2/3]; % Coefficients for injury value calculation
% Sample data for projects (number of lives saved and injuries prevented) projects = [ struct('livesSaved', 11, 'injuriesPrevented', 2), struct('livesSaved', 15, 'injuriesPrevented', 3), struct('livesSaved', 8, 'injuriesPrevented', 1) ];
% Initialize arrays to store results presentWorthValues = zeros(length(projects), 1); lowerBoundValues = zeros(length(projects), 1); upperBoundValues = zeros(length(projects), 1);
% Calculate present worth for each project for i = 1:length(projects) % Calculate the value from saving lives livesValueLower = projects(i).livesSaved * savingLifeRange(1); livesValueUpper = projects(i).livesSaved * savingLifeRange(2);
% Calculate the value from preventing injuries injuriesValueLower = projects(i).injuriesPrevented * ... (injuryFactor(1) * savingLifeRange(1) + injuryFactor(2) * savingLifeRange(1)); injuriesValueUpper = projects(i).injuriesPrevented * ... (injuryFactor(1) * savingLifeRange(2) + injuryFactor(2) * savingLifeRange(2));
% Total present worth calculations lowerBoundValues(i) = livesValueLower + injuriesValueLower; upperBoundValues(i) = livesValueUpper + injuriesValueUpper;
% Store total present worth (using midpoint for simplicity) presentWorthValues(i) = (lowerBoundValues(i) + upperBoundValues(i)) / 2; end
% Display results disp('Project Results:') for i = 1:length(projects) fprintf('Project %d: Lives Saved: %d, Injuries Prevented: %d\n', ... i, projects(i).livesSaved, projects(i).injuriesPrevented); fprintf('Total Present Worth (Lower Bound): $%.2f\n', lowerBoundValues(i)); fprintf('Total Present Worth (Upper Bound): $%.2f\n', upperBoundValues(i)); fprintf('Average Present Worth: $%.2f\n\n', presentWorthValues(i)); end
% Plotting results figure; bar(presentWorthValues); xlabel('Project Number'); ylabel('Average Present Worth ($)'); title('Average Present Worth of Highway Projects'); grid on;
Please see attached.
So, after going through above code, you will find a range setup for saving a life and factors for injury calculation. Information stored about each project in a structured format, calculated the lower and upper bounds of the total present worth based on lives saved and injuries prevented which outputs calculated values to the console. Finally, a bar graph represents the average present worth of each project. If applicable, you might also want to include external costs or benefits associated with highway projects to enhance your analysis.
Please let me know if you have any further questions.