Académique Documents
Professionnel Documents
Culture Documents
Problem 1
A particular circular cylindrical tank is 15 m tall and has a radius 8 m. We want to construct another cylindrical tank with a volume 20 % greater but having the same height. How large must its radius be?
Solution
r=8;
h=15; V= pi*r^2*h;
V=V+0.2*V or V=1.2*V;
r=sqrt(V/(pi*h))
Polynomial Roots
x3 - 7x2 + 40x 34 = 0 MATLAB commands; >>a= [1,-7,40,-34]; >>roots(a) ans = 3.0000 + 5.000i 3.0000 - 5.000i 1.0000
Saving Data
clear D = 2; v = 3; rho = 1000; mu = 0.001; NRe = D*v*rho/mu; f = 0.076*NRe^(-0.25); save data1 D v rho mu NRe f
Loading Data
clear load data1 who Your variables are:
D NRe
D D= 2
rho mu v
Problem:
Determine how many elements are in the array
cos(0):0.02: log10(100). Determine the 25th element. Find the roots of the polynomial 290-11x+6x2+ x3
Problem:
Plot the function s=2 sin(3t+2)+(5t+1) over the
interval 0<=t<=5. put a title on the plot and properly label the axes. The variable s represents speed in feet per second; the variable t represents time in seconds
Problem:
Use the Matlab to solve the following set of equations. 6x-4y+8z= 112 -5x+7z-3y=75 14x+9y-5z=-67
M-files
1.
2.
Script files; contains a sequence of MATLAB commands, and is useful when you need to use many commands or arrays with many elements. Function files; useful when you need to repeat the operation of a set of commands. You can create your own function files. (Detail in Chapter 3)
>> % Mass Transfer Program MATLAB ignores every thing to the right of the % symbol
Debugging
Debugging; process of finding and removing the
bugs or errors in a program. Syntax Error; related to typing or grammatical mistake, MATLAB detects it automatically. Runtime error; are due to incorrect formula or input. We have to find and fix it. e.g. Division by Zero.
Programming Style
1. 2. 3. 4.
Input/Output commands
disp (A) disp ( Text ) x = input ( text )
num2str command
% This m-file calculates the area of a circle, % and displays the result. radius = 2.5; area = pi * 2.5 ^ 2; disp (area)
Assignment
Problems: Section 1.1( 1 to 6 group 1) Section 1.1 (6 to 12 group 2) Section 1.3 (13 to 18 group 3) Section 1.3 (19 to 24 group 4)