You are here

Solution to Exercise 8.3

20 January, 2016 - 09:21

The m-file content:

The html output:

    %% Work done
% This script computes the work done on an object
clc
disp('A force F acting on a body at a distance s from a fixed point is given by')
disp('F=3*s+(1/(s^2)) where s is the distance in meters')
disp('Compute the total work done in moving')
disp('From the position where s=1 to that where s=10.')
disp(' ')                       % Display blank line
%% Create a row vector for distance, s
s=1:.001:10;
%% Compute Force for s
F=3.*s+(1./(s.^2));         % Computing Force for s
%% Integrating F*ds over 1 to 10 meters.
WorkDone=trapz(s,F)
media/image8.png
Figure 8.7 The published html file.