0% found this document useful (0 votes)
12 views2 pages

MATLAB Command Window: 'Height' 'Pressure' 'Height Against Pressure Graph'

The document contains MATLAB code for solving multiple physics problems involving calculations of pressure, volume, and matrix operations. It includes code to calculate pressure given density, gravitational acceleration, and height. It also includes plotting a graph of height vs pressure and performing matrix operations like combining matrices horizontally and extracting submatrices.

Uploaded by

najwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

MATLAB Command Window: 'Height' 'Pressure' 'Height Against Pressure Graph'

The document contains MATLAB code for solving multiple physics problems involving calculations of pressure, volume, and matrix operations. It includes code to calculate pressure given density, gravitational acceleration, and height. It also includes plotting a graph of height vs pressure and performing matrix operations like combining matrices horizontally and extracting submatrices.

Uploaded by

najwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MATLAB Command Window Page 1

>> %QUESTION 1(a)


%%given data
d = 1600;%density
g = 9.8;%gravitational
h = 40;%height
%EQN
p = d*g*h;
p = 1600*9.8*40

%QUESTION 1(b)
%%given data
h = [10:5:60];%height
p = d*g*h;%formula for pressure
plot(h, p),xlabel ('height'),ylabel ('pressure'),title('height against pressure
graph')

%QUESTION 2
%%given data
A = [1 2 3;4 5 4;7 8 9];%matrik A
B = [ 1 4 9];%matrix B
C = [8;9;7];%matrix C

%QUESTION 2(i)
D = [4 5 4]

%QUESTION 2(ii)
%%given data
D = [4 5 4];
B = [1 4 9];

E = [D;B]

%QUESTION 2(iii)
%%given data
A = [1 2 3;4 5 4;7 8 9];

F = [1;5;9]

%QUESTION 2(iv)
%%given data
A = [1 2 3;4 5 4;7 8 9];

G = [7 8 9]

%QUESTION 3
R = [0:3:12];%radius
H = [10:2:20];%height
V = pi.*R^2.*H %volume
MATLAB Command Window Page 2

p =

6.2720e+05

D =

4 5 4

E =

4 5 4
1 4 9

F =

1
5
9

G =

7 8 9

Error using ^ (line 51)


Incorrect dimensions for raising a matrix to a power. Check that the matrix is square
and the power is a scalar. To perform elementwise matrix powers,
use '.^'.

>>

You might also like