Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11 views

Engineering Computer Applications-Lec1

Uploaded by

jana.hisham756
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Engineering Computer Applications-Lec1

Uploaded by

jana.hisham756
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Engineering

Computer
Applications
MATLAB
Introduction to MATLB

MATLAB Variables

MATLAB Built-in Functions

Matrices Operations

Course Polynomials

Complex Numbers

Agenda Plotting

Programming

User-defined Functions

Image Handling using MATLAB

Simulink
Introduction to MATLAB
• MATLAB came from Matrix Laboratory or Mathematics Laboratory
• All variables are treated as matrices.
• MATLAB plays a crucial role in engineering and computer applications due to its powerful
computational abilities, extensive toolboxes, and versatility for solving complex mathematical,
scientific, and engineering problems.
• Mathematical Modeling and Simulation
• Data Analysis and Visualization
• Control Systems Design
• Signal and Image Processing
• Optimization and Numerical Analysis
• Embedded Systems Development
• Communication Systems Design
• Machine Learning and AI
• Automation and Robotics
• MATLAB is also a high-level programming language, and the platform offers great flexibility to use
with other programming languages, e.g., Python, C/C++, Java, etc.
Introduction to Matlab: Matlab interface

Current Directory

Current Folder

Workspace

Command Window
Command History

m file comment
Introduction to Matlab: Matlab interface
Introduction to Matlab
• Getting help
➢Use help to request info on a specific function
➢ displays help in the command window
>> help sqrt

➢Use doc function to open the help browser


window
>> doc plot

➢Use lookfor to find function by keywords


>> lookfor regression
MATLAB Variables
• Variables are created when they are used .
• Actually, all variables in MATLAB are matrices.
• Scalars are 1-by-1 matrices
• vectors are N-by-1 (or 1-by-N) matrices.
• You can see this by executing
>> x=5
>> size(x)
• No need for types. i.e.,
Example:
>>x=5;
• All variables are created with double precision >>x1=2;
Matrices
• Entering scalar
• >>a= 1;

• Entering a vector
>> A = [1 2 3];

• Entering a matrix:
>> B=[1 2 3; 4 5 6];
• Matrix indices begin from 1 (not 0!!!)

• Entering a string:
>> C = ‘Hello World!';
MATLAB Built-in Functions
• Elementary matrices functions
➢ zeros(m,n)
➢ ones(m,n)
➢ eye(m,n)
➢ diag(A)
➢ rand(m,n)
➢ randn(m,n)
➢ logspace(a,b,n)
➢ linspace (a,b,n)
➢ ….
Matrices Operations
• Accessing Matrix Elements
• A(2,3)
• A(:,2)
• A(end,:)
• A([1,2],[1,3])
• A(1:2,3:end)

• Matrix Operations
• + addition
• - subtraction
• * multiplication
• ^ power
• And, or, not
M_FIle
• Click to create
• a new M-File

• A text file containing script or function


• Extension “.m”
Polynomials in Matlab
• Polynomials in Matlab can be represented as
• a vector of coefficients (polynomial form)
>>P(x)=3x3+2x2−5x+7.
>>P = [3 2 -5 7];

• Using its symbols(symbolic form)


>>syms x;
>>P=3*x^3+2*x^2−5*x+7
Complex Numbers
• Define a complex number:
>>z = 3 + 4i;
• Rectangular form : z = 3 + 4i
• Real part: real(z);
• Imaginary part: imag(z);

• Polar Form: z=r∟ᶿ


• Modulus: abs(z);
• Phase: angle(z);

• Polar to rectangular conversion: r * exp(1i * theta);


• Rectangular to polar conversion: abs(z); and angle(z);
Plotting
plot, plot3d, bar, grid, subplot,….
MATLAB Programming
• a collection of commands
executed in sequence
• Flow Control
• if, for, while ….

• stored in “.m” file


• no input or output arguments
User-defined Functions
• Accepts input and returns output to the caller
• functions operate on variables within their own function workspace (scope)
• The first command line of the file must have this format:
function[list of outputs]=functionname(list of inputs)
…….
• Save the function as a m-file
• Call the function using the filename (not the function name).
Image Handling
Simulink
• Simulink a versatile MATLAB tool for
modeling, simulating, and analyzing
dynamic systems.
• It is especially useful for systems that
evolve over time, like control systems,
signal processing systems, mechanical
systems, electrical circuits, and other
dynamic systems.
• Simulink allows for model-based
design.
Course year work distribution
40 mark -------→ final exam

Practical exam
20 mark-------→ Midterm quiz

Online quiz
20 mark-------→ Practical
Project, assignment,…..

20 mark------→ lecture
Thanks

You might also like