You are here

Solution to Exercise 4.4

9 October, 2015 - 14:47
 This script computes the load carried by the larger piston in a hydraulic system 
 clc                        % Clear screen 
 disp('This script computes the load carried by the larger piston in a hydraulic system') 
 disp(' ')                  % Display blank line 
 initialF=input('Enter the initial force in N: '); 
 finalF=input('Enter the final force in N: '); 
 increment=input('Enter the increment value: '); 
 area1=input('Enter the area of small piston in mm^2: '); 
 area2=input('Enter the area of big piston in mm^2: '); 
 F1=[initialF:increment:finalF]; % Creating a row vector with F1 values 
 F2=F1*area2/area1; % Calculating F2 values 
 disp(' ')                  % Display blank line 
 str = [' F1 F2 '];% Displaying table header 
 disp(str); 
 disp([F1' F2']) % Tabulating results in two columns, ' is being used to transpose row to column 

 

The script output is as follows:

This script computes the load carried by the larger piston in a hydraulic system

Enter the initial force in N: 150
Enter the final force in N: 200
Enter the increment value: 10
Enter the area of small piston in mm^2: 25
Enter the area of big piston in mm^2: 100

F1    F2
150  600
160  640
170  680
180  720
190  760
200  800