This document provides an overview of MATLAB including its history, applications, development environment, built-in functions, and toolboxes. MATLAB stands for Matrix Laboratory and was originally developed in the 1970s at the University of New Mexico to provide an interactive environment for matrix computations. It has since grown to be a comprehensive programming language and environment used widely in technical computing across many domains including engineering, science, and finance. The key components of MATLAB are its development environment, mathematical function library, programming language, graphics capabilities, and application programming interface. It also includes a variety of toolboxes that provide domain-specific functionality in areas like signal processing, neural networks, and optimization.
In MATLAB, a vector is created by assigning the elements of the vector to a variable. This can be done in several ways depending on the source of the information.
—Enter an explicit list of elements
—Load matrices from external data files
—Using built-in functions
—Using own functions in M-files
Matlab is basically a high level language which has many specialized toolboxes for making things easier for us.
Matlab stands for MATrix LABoratory.
The first version of MATLAB was produced in the mid 1970s as a teaching tool. MATLAB started as an interactive program for doing matrix calculations.
MATLAB has now grown to a high level mathematical language that can solve integrals and differential equations numerically and plot a wide variety of two and three Dimensional graphs.
The expanded MATLAB is now used for calculations and simulation in companies and government labs ranging from aerospace, car design, signal analysis through to instrument control and financial analysis.
In practice, it provides a very nice tool to implement numerical method.
- The desktop includes these panels:
Current Folder — Access your files.
Command Window — Enter commands at the command line, indicated by the prompt (>>).
Workspace — Explore data that you create or import from files.
- what we learn:
1- Introduction to Matlab.
2- MATLAB InstallationVersion 2018.
3- Assignment.
4- Operations in MATLAB.
5- Vectors and Matrices in MATLAB.
In MATLAB, a vector is created by assigning the elements of the vector to a variable. This can be done in several ways depending on the source of the information.
—Enter an explicit list of elements
—Load matrices from external data files
—Using built-in functions
—Using own functions in M-files
Matlab is basically a high level language which has many specialized toolboxes for making things easier for us.
Matlab stands for MATrix LABoratory.
The first version of MATLAB was produced in the mid 1970s as a teaching tool. MATLAB started as an interactive program for doing matrix calculations.
MATLAB has now grown to a high level mathematical language that can solve integrals and differential equations numerically and plot a wide variety of two and three Dimensional graphs.
The expanded MATLAB is now used for calculations and simulation in companies and government labs ranging from aerospace, car design, signal analysis through to instrument control and financial analysis.
In practice, it provides a very nice tool to implement numerical method.
- The desktop includes these panels:
Current Folder — Access your files.
Command Window — Enter commands at the command line, indicated by the prompt (>>).
Workspace — Explore data that you create or import from files.
- what we learn:
1- Introduction to Matlab.
2- MATLAB InstallationVersion 2018.
3- Assignment.
4- Operations in MATLAB.
5- Vectors and Matrices in MATLAB.
A basic overview, application and usage of MATLAB for engineers. It covered very basics essential that will help one to get started with MATLAB programming easily.
Provided by IDEAS2IGNITE
The frame work that I used for my Introduction to Matlab hour long course. Most of the instruction took place on a live Matlab screen, but this provided the framework
A Powerpoint Presentation designed to provide beginners to MATLAB an introduction to the MATLAB environment and introduce them to the fundamentals of MATLAB including matrix generation and manipulation, Arrays, MATLAB Graphics, Data Import and Export, etc
A short presentation on the topic Numerical Integration for Civil Engineering students.
This presentation consist of small introduction about Simpson's Rule, Trapezoidal Rule, Gaussian Quadrature and some basic Civil Engineering problems based of above methods of Numerical Integration.
Introduction to Matlab
Lecture 1:
Introduction: What is Matlab, History of Matlab, strengths, weakness
Getting familiar with the interface: Layout, Pull down menus
Creating and manipulating objects: Variables (scalars, vectors, matrices, text strings), Operators (arithmetic, relational, logical) and built-in functions
Differential Equations Lecture: Non-Homogeneous Linear Differential Equationsbullardcr
A lecture I presented in Differential Equations, Spring 2006. This was supplemented with a hands-on solution to a random problem with variables designated by students in the class.
A basic overview, application and usage of MATLAB for engineers. It covered very basics essential that will help one to get started with MATLAB programming easily.
Provided by IDEAS2IGNITE
The frame work that I used for my Introduction to Matlab hour long course. Most of the instruction took place on a live Matlab screen, but this provided the framework
A Powerpoint Presentation designed to provide beginners to MATLAB an introduction to the MATLAB environment and introduce them to the fundamentals of MATLAB including matrix generation and manipulation, Arrays, MATLAB Graphics, Data Import and Export, etc
A short presentation on the topic Numerical Integration for Civil Engineering students.
This presentation consist of small introduction about Simpson's Rule, Trapezoidal Rule, Gaussian Quadrature and some basic Civil Engineering problems based of above methods of Numerical Integration.
Introduction to Matlab
Lecture 1:
Introduction: What is Matlab, History of Matlab, strengths, weakness
Getting familiar with the interface: Layout, Pull down menus
Creating and manipulating objects: Variables (scalars, vectors, matrices, text strings), Operators (arithmetic, relational, logical) and built-in functions
Differential Equations Lecture: Non-Homogeneous Linear Differential Equationsbullardcr
A lecture I presented in Differential Equations, Spring 2006. This was supplemented with a hands-on solution to a random problem with variables designated by students in the class.
MATLAB program are stored as script file(.m files). This type of file contains MATLAB commands, so running it is equivalent to typing all the commands—one at a time—at the Command window prompt. You can run the file by typing its name at the Command window.
Matlab Programming Assignment help , Matlab Programming Online tutorsjohn mayer
Get the 24/7 tutors for Matlab Programming Assignment help & Matlab Programming homework help. Matlab Programming tutors are available 24/7 in order to provide the complete academic assistance for the Matlab Programming assignments.
http://www.globalwebtutors.com/matlab-programming-assignment-help
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkreddyprasad reddyvari
3 days Hands on workshop on MATLAB/SIMULINK for Engineering Applications:
this workshop aims to make students to aware of MATLAB to do own projects in engineering life with best available technology E-Simulink Softwares and tools.
1. Introduction to MATLAB and programming
2. Workspace, variables and arrays
3. Using operators, expressions and statements
4. Repeating and decision-making
5. Different methods for input and output
6. Common functions
7. Logical vectors
8. Matrices and string arrays
9. Introduction to graphics
10. Loops
11. Custom functions and M-files
CETPA INFOTECH PVT LTD is one of the IT education and training service provider brands of India that is preferably working in 3 most important domains. It includes IT Training services, software and embedded product development and consulting services.
http://www.cetpainfotech.com
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Strategies for Successful Data Migration Tools.pptxvarshanayak241
Data migration is a complex but essential task for organizations aiming to modernize their IT infrastructure and leverage new technologies. By understanding common challenges and implementing these strategies, businesses can achieve a successful migration with minimal disruption. Data Migration Tool like Ask On Data play a pivotal role in this journey, offering features that streamline the process, ensure data integrity, and maintain security. With the right approach and tools, organizations can turn the challenge of data migration into an opportunity for growth and innovation.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
4. o MATLAB Application & usage
o MATLAB Environment
o MATLAB Variables
o MATLAB Operations.
o MATLAB Built-in Fun.
o MATLAB Scripts.
5. MATLAB stands for matrix laboratory.
o High-performance language for
technical computing.
o Integrates computation,
visualization, and programming in
an easy-to-use environment where
problems and solutions are
expressed in familiar mathematical
notation.
6. o Math and computation
o Algorithm development
o Data acquisition
o Modeling, simulation, and prototyping
o Data analysis, exploration, and visualization
o Scientific and engineering graphics
o Application development, including
graphical user interface building
The MATLAB Application:
7. The MATLAB system have five main parts:
1. Development Environment.
2. The MATLAB Mathematical Function Library.
3. The MATLAB Language.
4. Graphics.
5. The MATLAB Application Program Interface (API).
Code Generation
Blocksets
PC-based real-time
systems
StateflowStateflowStateflow
Toolboxes
DAQ cards
Instruments
Databases and files
Financial Datafeeds
Desktop Applications
Automated Reports
8. StatisticsStatistics Toolbox
o Contains about 250 functions and GUI’s for:
generating random numbers, probability
distributions, hypothesis Testing, statistical
plots and covers basic statistical functionality
Signal Processing Toolbox
o An environment for signal analysis
waveform generation, statistical signal
processing, and spectral analysis
o Useful for designing filters in conjunction with
the image
processing toolbox
Signal Processing
9. Neural Network Toolbox
o GUI for creating, training, and simulating
neural networks.
o It has support for the most commonly used
supervised
Optimization Toolbox
o Includes standard algorithms for optimization
o Including minimax, goal attainment, and semi-
infinite minimization problems
Neural Networks
Optimization
10. Curve Fitting Toolbox
o Allows you to develop custom linear and
nonlinear models in a graphical user interface.
o Calculates fits, residuals, confidence intervals,
first derivative and integral of the fit.
Another Tool boxes :
o Communications Toolbox
o Control System Toolbox
o Data Acquisition Toolbox
o Database Toolbox
o Image Processing Toolbox
o Filter Design Toolbox
o Financial Toolbox
o Fixed-Point Toolbox
o Fuzzy Logic Toolbox
11. 11/14
o Simulink is a graphical, “drag and drop” environment for building
simple and complex signal and system dynamic simulations.
o It allows users to concentrate on the structure of the problem, rather
than having to worry (too much) about a programming language.
o The parameters of each signal and system block is configured by the
user (right click on block)
o Signals and systems are simulated over a particular time.
vs,vc
t
12. o .fig
MATLAB Figure
o .m
MATLAB function, script, or class
o .mat
MATLAB binary file for storing variables
o .mex
MATLAB executable (platform specific, e.g. ".mexmac" for the Mac, ".mexglx" for Linux)
15. o In the mid-1970s, Cleve Moler and several colleagues
developed 2 FORTRAN libraries
• LINPACK for solving linear equations
• EISPACK for solving eigenvalue problems.
o In the late 1970s, Moler, “chairman of the computer science at the
University of New Mexico”, wanted to teach students linear
algebra courses using the LINPACK and EISPACK software.
o He didn't want them to have to program in FORTRAN, because
this wasn't the purpose of the course.
16. o He wrote a program that provide simple interactive access to
LINPACK and EISPACK.
o Over the next years, when he visit another university, he leave a
copy of his MATLAB.
o In 1983, second generation of MATLAB was devoloped written
in C and integrated with graphics.
o The MathWorks, Inc. was founded in 1984 to market and
continue development of MATLAB.
18. Command window
• save filename % save data from workspace to a file
• load filename % loads data from file to a workspace
• who % list variables exist in the workspace
• whos % list variables in details
• clear % clear data stored in the workspace
• clc % clears the command window
• ctrl+c % To abort a command
• exit or quit % to quit MATLAB
19. Command window
• Through Command window:
o help command
Ex: >> help plot
o lookfor anystring
Ex: >> lookfor matrix
• Through Menus: (Using help window)
o doc command
Ex: >> doc plot
20. • To create a variable, simply assign a value to a name:
»var1=3.14
»myString=‘hello world’
• Variable name must start with letter.
• It is case sensitive (var1 is different from Var1).
• To Check the variable name validation ‚isvarname *name+‛
o isvarname X_001
o isvarname if
• To check the Max length supported by current MATLAB
version ‚namelengthmax‛
21. o MATLAB is a weakly typed language
No need to declear variables!
o MATLAB supports various types, the most often used are
»3.84
64-bit double (default)
»‘a’
16-bit char
o Most variables are vectors or matrices of doubles or chars
o Other types are also supported:
complex, symbolic, 16-bit and 8 bit integers.
22. • Variable can’t have the same name of keyword
oUse ‚iskeyword‛ to list all keywords
• Built-in variables. Don’t use these names!
o i and j can be used to indicate complex numbers
o Pi has the value 3.1415
o ans stores the last unassigned value (like on a calculator)
o Inf and –Inf are positive and negative infinity
o NaN represents ‘Not a Number’
Variables
23. • Warning:
MATLAB allows usage of the names of the built in function.
This is dangerous since we can overwrite the meaning of a
function.
• To check that we can use:
>> which sin ...
C:MATLABtoolboxmatlabelfun...
>> which ans < ans is a variable.
Variables
24. • A variable can be given a value explicitly
»a = 10
shows up in workspace!
• Or as a function of explicit values and existing variables
»c = 1.3*45-2*a
• To suppress output, end the line with a semicolon
»cooldude = 13/3;
1-Scaler:
25. • Like other programming languages, arrays are an important
part of MATLAB
• Two types of arrays:
1) Matrix of numbers (either double or complex)
2) Cell array of objects (more advanced data structure)
2-Array:
26. • comma or space separated values between brackets
»row = [1 2 5.4 -6.6]
»row = [1, 2, 5.4, -6.6];
• Command window:
• Workspace:
Row Vector:
28. • The difference between a row and a column vector can get by:
o Looking in the workspace
o Displaying the variable in the command window
o Using the size function
• To get a vector's length, use the length function
Vectors:
30. • Make matrices like vectors
• Element by element
» a= [1 2;3 4];
• By concatenating vectors or matrices (dimension matters)
Matrix:
31. • ones:
>> x = ones(1,7) % All elements are ones
• zeros:
>> x = zeros(1,7) % All elements are zeros
• eye:
>> Y = eye(3) % Create identity matrix 3X3
• diag:
>> x = diag([1 2 3 4],-1) % diagonal matrix with main
diagonal shift(-1)
32. • magic:
>> Y = magic(3) %magic square matrix 3X3
• rand:
>> z = rand(1,4) % generate random numbers
from the period [0,1] in a vector 1x4
• randint:
>> x = randint(2,3, [5,7]) % generate random integer
numbers from (5-7) in a matrix 2x3
33. • Arithmetic Operators: + - * / ^ ‘
• Relational Operators: < > <= >= == ~=
• Logical Operators: Element wise & | ~
• Logical Operators: Short-circuit && ||
• Colon: (:)
Operation Orders:
Precedence Operation
1 Parentheses, innermost 1st.
2 Exponential, left to right
3 Multiplication and division, left to right
4 Addition and subtraction, left to right
34. • Addition and subtraction are element-wise ‛ sizes must match‛:
• All the functions that work on scalars also work on vectors
»t = [1 2 3];
»f = exp(t);
is the same as
»f = [exp(1) exp(2) exp(3)];
35. • Operators (* / ^) have two modes of operation:
1-element-wise :
• Use the dot: .(.*, ./, .^). ‚BOTH dimensions must match.‛
»a=[1 2 3]; b=[4;2;1];
»a.*b, a./b, a.^b all errors
»a.*b', a./b’, a.^(b’) all valid
36. • Operators (* / ^) have two modes of operation:
2-standard:
• Standard multiplication (*) is either a dot-product or an outer-
product
• Standard exponentiation (^) can only be done on square
matrices or scalars
• Left and right division (/ ) is same as multiplying by inverse
37. o min(x); max(x) % minimum; maximum elements
o sum(x); prod(x) % summation ; multiplication of all elements
o length(x); % return the length of the vector
o size(x) % return no. of row and no. of columns
o anyVector(end) % return the last element in the vector
o find(x==value) % get the indices
o [v,e]=eig(x) % eign vectors and eign values
Exercise:
>>x = [ 16 3 2 13 ; 5 10 11 8 ; 9 6 7 12 ; 4 15 14 1 ]
38. o fliplr(x) % flip the vector left-right
o Z=X*Y % vectorial multiplication
o y= sin(x).*exp(-0.3*x) % element by element multiplication
o mean %Average or mean value of every column.
o transpose(A) or A’ % matrix Transpose
o sum((sum(A))')
o diag(A) % diagonal of matrix
Exercise:
>>x = [ 16 3 2 13 ; 5 10 11 8 ; 9 6 7 12 ; 4 15 14 1 ]
40. • MATLAB indexing starts with 1, not 0
• a(n) returns the nth element
• The index argument can be a vector.
In this case, each element is looked up individually, and
returned as a vector of the same size as the index vector.
Indexing:
41. • Matrices can be indexed in two ways
using subscripts(row and column)
using linear indices(as if matrix is a vector)
Matrix indexing: subscripts or linearindices
• Picking submatrices:
Indexing:
42. • To select rows or columns of a matrix:
Indexing:
43. • To get the minimum value and its index:
»[minVal , minInd] = min(vec);
maxworks the same way
• To find any the indices of specific values or ranges
»ind = find(vec == 9);
»[ind_R,ind_C] = find(vec == 9);
»ind = find(vec > 2 & vec < 6);
Indexing:
44. >> X =[ 16 3 2 13 ; 5 10 11 8 ; 9 6 7 12 ; 4 15 14 1 ]
>>X(:,2) = [] % delete the second column of X
X =
16 2 13
5 11 8
9 7 12
4 14 1
Deleting Rows & Columns:
45. • Scripts are
o collection of commands executed in sequence
o written in the MATLAB editor
o saved as MATLAB files (.m extension)
• To create an MATLAB file from command-line
»edit helloWorld.m.
• or click
46.
47. • COMMENT!
o Anything following a % is seen as a comment
o The first contiguous comment becomes the script's help file
o Comment thoroughly to avoid wasting time later
• All variables created and modified in a script exist in the
workspace even after it has stopped running
48. • Generate random vector to represent the salaries of 10
employees that in range of 700-900 L.E. Then present some
statistic about these employees salaries :
o Max. Salary
o Empl. Max_ID
o Min. Salary
o Empl. Min_ID
49. • Generate random vector to represent the salaries of 10
employees that in range of 700-900 L.E.
clear;
clc;
close all;
Salaries =randint(1,10,[700,900]);
MaxSalary = max(Salaries); % Max. Salary
EmplMax_ID = find(Salaries==MaxSalary); %Empl. Max_ID
MinSalary = min(Salaries); %Min. Salary
EmplMin_ID = find(Salaries==MinSalary); %Empl. Min_ID
50. • Any variable defined as string is considered a vector of
characters, dealing with it as same as dealing with vectors.
>> str = ‘hello matlab’;
>> disp(str)
>> msgbox(str)
>> Num = input(‘Enter your number:’)
>> str = input(‘Enter your name:’,’s’)
-----------------------------------------------------------------------------
>> str = ‘7234’
>> Num = str2num(str)
>> number = 55
>> str = num2str(number)
52. Plot in 2-D:
• label the axes and add a title:
xlabel('x = 0:2pi')
ylabel('Sine of x')
title('Plot of the Sine Function’,'FontSize',12)
53. Plot in 2-D:
• Multiple Data Sets in One Graph
x = 0:pi/100:2*pi;
y = sin(x);
y2 = sin(x-.25);
y3 = sin(x-.5);
plot(x,y,x,y2,x,y3)
• legend('sin(x)','sin(x-.25)','sin(x-.5)')
54. Plot in 2-D:
• Line color
plot(x,y,'color_style_marker')
o Color strings are 'c', 'm', 'y', 'r', 'g', 'b', 'w', 'k'.
o These correspond to cyan, magenta, yellow, red, green, blue,
white, and black.
• Line Style
plot(x,y,'color_style_marker')
• Line Marker
USE MATLAB HELP
56. Plot in 2-D:
• All Properties Of Plot Command :
plot(x,y,'--rs',<
'LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',10)
57. Plot in 2-D:
• Imaginary and Complex Data:
t = 0:pi/10:2*pi;
Z=exp(i*t);
plot(real(z),imag(z))
OR
plot(z)
58. Exercise:
Plot the vector y with respect the vector x in
the XY plan considering style:
o Dotted line
o diamond marker
o green color
o line width of 3
59. Plot in 2-D:
• Adding Plots to an Existing Graph:
x1 = 0:pi/100:2*pi;
x2 = 0:pi/10:2*pi;
plot(x1,sin(x1),'r:‘)
hold on
plot(x2,sin(x2),'r+')
hold off
60. Plot in 2-D:
• Figure Windows
o figure
o figure(n)
where n is the number in the figure title bar.
• Multiple Plots in One Figure:
x = linspace(0,2*pi,100);
y = sin(x);
y1 = cos(x);
subplot 211
plot(x, y);
subplot 212
plot(x, y1);
• area(x, y); %% think what
happened ??!!!
0 1 2 3 4 5 6 7
-1
-0.5
0
0.5
1
0 1 2 3 4 5 6 7
-1
-0.5
0
0.5
1
61. Plot on 3D:
t = 0:0.1:2*pi;
x = sin(t);
y = cos(t);
plot3(x,y,t)
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
-1
-0.5
0
0.5
1
0
1
2
3
4
5
6
7
62. Plot surface in the 3D :
x = linspace(1,10,20);
y = linspace(1,5,10);
[XX,YY] = meshgrid(x,y);
ZZ = sin(XX)./exp(YY);
mesh(ZZ)
0
2
4
6
8
10
12
14
16
18
20
0
2
4
6
8
10
-0.4
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
63. Specialized Plotting Functions:
polar : to make polar plots
»polar(0:0.01:2*pi,cos((0:0.01:2*pi)*2))
•bar : to make bar graphs
»bar(1:10,rand(1,10));
•stairs : plot piecewise constant functions
»stairs(1:10,rand(1,10));
•fill : draws and fills a polygon with specified vertices
»fill([0 1 0.5],[0 0 1],'r');
64. Axes Control:
• For tow-dimensional graphs:
>>axis([xmin xmax ymin ymax])
• For three-dimensional graphs:
>>axis([xmin xmax ymin ymax zmin zmax])
• To reenable MATLAB automatic limit selection:
>>axis auto
• makes the x-axis and y-axis the same length:
>>axis square
65. Axes Control:
• Makes the axes visible (This is the default):
>>axis on
• Makes the axes invisible:
>>axis off
• Turns the grid lines on:
>>grid on
• Turns them back off again:
>>grid off
66. Exercise:
Plot the vector y with respect the vector x in
the XY plan considering style:
o Dotted line
o diamond marker
o green color
o line width of 3
67. Relational Operators:
•MATLAB uses mostlystandard relational operators
equal ==
notequal ~=
greater than >
less than <
greater or equal >=
less or equal <=
•Logical operatorselementwiseshort-circuit (scalars)
And &&
Or ||
Not~
Xor xor
•Boolean values: zero is false, nonzero is true
68. Relational Operators:
•MATLAB uses mostlystandard relational operators
equal ==
notequal ~=
greater than >
less than <
greater or equal >=
less or equal <=
•Logical operatorselementwiseshort-circuit (scalars)
And &&&
Or |||
Not~
Xor xor
•Boolean values: zero is false, nonzero is true
69. If / else / elseif :
• Basic flow-control, common to all languages
• MATLAB syntax is somewhat unique
• No need for parentheses : command blocks are between reserved
words
70. If / else / elseif :
a= input( ‘A‘ )
if rem(a,2) ==0
msgbox(‘a is even’);
end
71. If / else / elseif :
a= input( ‘A’ )
if rem(a,2) ==0
msgbox(‘a is even’);
else
msgbox(‘a is odd’);
end
72. If / else / elseif :
if y < 0
M = y + 3;
elseif y > 5
M = y – 3;
else
M = 0;
End
M
74. Switch case:
• SWITCH expression must be a scalar or string constant.
• Unlike the C language switch statement, MATLAB switch does not
fall through.
If the first case statement is case statements do not execute.
• So, break statements are not required.
75. For Loop :
• For loops : use for a known number of iterations
• MATLAB syntax:
• The loop variable:
o Is defined as a vector
o Is a scalar within the command block
o Does not have to have consecutive values (but it's usually cleaner
if they're consecutive)
• The command block:
o Anything between the for line and the end
76. For Loop :
for n = 1:32
r(n) = n;
end
r
• Nested For Loop
for m = 1: 5
for n = 1: 7
A(m,n) = 1/(m+n-1);
end
end
77. While loop:
• The while is like a more general for loop:
• Don't need to know number of iterations
• The command block will execute while the conditional expression is
true
o Beware of infinite loops!
78. While loop:
x = 1;
while (x^2<10)
y=x^2;
plot(x,y,’or’); hold on
x = x+1;
end
79. Continue:
• The continue statement passes control to the next iteration of the loop
• Skipping any remaining statements in the body of the loop.
• In nested loops, continue passes control to the next iteration of the
loop enclosing it.
x=1;
for m=1:5
if (m==3)
continue;
end
x=m+x;
end
x
80. Continue:
• The continue statement passes control to the next iteration of the loop
• Skipping any remaining statements in the body of the loop.
• In nested loops, continue passes control to the next iteration of the
loop enclosing it.
• Example: x=1;
for m=1:5
if (m==3)
continue;
end
x=m+x;
end
x
81. Break:
• The break statement lets you exit early from a for loop or while loop.
• In nested loops, break exits from the innermost loop only.
• Example:
x=1;
for m=1:5
if (m==3)
break;
end
x=m+x;
end
x
83. User-defined Functions:
Functions look exactly like scripts, but for ONE difference
Functions must have a function declaration.
No need for return :
MATLAB 'returns' the variables whose names match those in the
function declaration.
85. User-defined Functions:
MATLAB provides three basic types of variables:
Local Variables:
Each MATLAB function has its own local variables.
Global Variables:
If several functions, and possibly the base workspace, all
declare a particular name as global, then they all share a
single copy of that variable.
Persistent Variables:
You can declare and use them within M-file functions only.
Only the function in which the variables are declared is
allowed access to it.
86. User-defined Functions:
%this fun. To sum 2 no’s.
function x=SUM2(a,b)
global z
x=a+b+z;
end
%this fun. To sum 2 no’s.
function x=SUM2(a,b)
x=a+b;
end
87. Matrix :
1-One dimension matrix
Only one row or one column (vector)
2-Two dimensions
Has rows and columns
3-three dimension matrix (multidimensional array)
Has rows, columns and pages.
90. Cell Array:
• Used to store different data type (classes) like vectors, matrices,
strings,<etc in single variable.
• Variables declaration:
>> X=3
>> Y=[1 2 3;4 5 6]
>> Z(2,5)=15
>> A(4,6)=[3 4 5] %…..(wrong)
• cell array:
>> C{1}=[2 3 5 10 20]
>> C{2}=‘hello’
>> C{3}=eye(3)
1 0 0
0 1 0
0 0 1
C
2 3 5 10 20 h e l l o
91. Cell Array:
Z{2,5} = linspace(0,1,10)
Z{1,3} = randint(5,5,[0 100])
Z{1,3}(4,2) =77
Note:
• The default for cell array elements is empty
• The default for matrix elements is zero
77
Z
92. Structure Array:
• Variables with named ‚data container‛ called fields.
• The field can contain any kind of data.
• Example:
>> Student.name=‘Ali’;
>> Student.age=20;
>> Student.grade=‘Excellent’;
Student
age
name grade
95. Structure Array:
• The need of Structure Array
x.y.z = 3
x.y.w = [ 1 2 3]
x.p = ‘hello’
• Note: x can be array
96. Symbolic Variable:
• syms x t
• x = sin(t)*exp(-0.3*t);
• sym(2)/sym(5)
• ans =
• 2/5
• sym(2)/sym(5) + sym(1)/sym(3)
• ans =
• 11/15
97. findsym :
>> syms a b n t x z
>> f = x^n; g = sin(a*t + b);
>> findsym(f)
• ans =n, x
>> findsym(g)
• ans =a, b, t
98. subs :
>> f = 2*x^2 - 3*x + 1
>> subs(f,2)
ans =3
>> syms x y
>> f = x^2*y + 5*x*sqrt(y)
>> subs(f, x, 3)
ans = 9*y+15*y^(1/2)
>> subs(f, y, 3)
ans = 3*x^2+5*x*3^(1/2)
99. Symbolic Matrix:
>> syms a b c
>> A = [a b c; b c a; c a b]
A =[ a, b, c ]
[ b, c, a ]
[ c, a, b ]
>> sum(A(1,:))
ans = a+b+c
>> sum(A(1,:)) == sum(A(:,2)) % This is a logical test.
ans =1
100. Simple:
• Simplify the expression.
>> syms x
>> m = sin(x)/cos(x)
>> simple(m)
• Show expression in a user friendly format
>> m = sin(x)/cos(x)
>> pretty(m)
Pretty:
101. Symbolic Plots:
• ezplot(...)
• Symbolic expression plot in the 2D
>> y = sin(x)*exp(-0.3*x)
>> ezplot(y,0,10)
• ezmesh(..)
• Symbolic expression plot in the 3D
>> z = sin(a)*exp(-0.3*a)/(cos(b)+2)
>> ezmesh(z,[0 10 0 10])
103. Differentiation diff :
• Numerical Difference or Symbolic Differentiation
>> z = [1, 3, 5, 7, 9, 11];
>> dz = diff(z)
>> Syms x t
>> x=t^4;
>> xd3 = diff(x,3)
104. Differentiation diff(…) :
>> syms s t
>> f = sin(s*t)
>> diff(f,t)
ans = cos(s*t)*s
>> diff(f,t,2)
ans =-sin(s*t)*s^2
>> diff(y)./diff(x)
105. Integration int(…)
• Symbolic integration
>> int(y)
• Integration from 0 to 1
>> int(x,0,1)
• Integration from 0 to 2
>> int(x,0,2)
106. solve equation solve(...):
>> syms x y real
>> eq1 = x+y-5
>> eq2 = x*y-6
>> [xa, ya] = solve(eq1, eq2)
OR
>> answer = solve(eq1, eq2)
answer.x
answer.y
>> syms x y real
>> s = solve('x+y=9','x*y=20')
107. Differential Equations dsolve(..):
• Symbolic solution of ordinary differential equations
>> syms x real
>> diff_eq_sol = dsolve('m*D2x+b*Dx+k*x=0','Dx(0)=-1','x(0)=2')
>> syms m b k real
>> subs(diff_eq_sol, [m,b,k], [2,5,100])