Matlab is an interactive computing environment for numerical computation, visualization, and programming. The document provides an introduction and overview of Matlab, including what Matlab is, the Matlab screen interface, variables and arrays, basic math operations, plotting functions, control structures like if/else and for loops, using m-files, and writing user-defined functions. Key features of Matlab covered are the command window, workspace, command history, generating matrices and vectors, element-wise operations, relational and logical operators, and file input/output statements.
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.
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.
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
Computers and Programming , Programming Languages Types, Problem solving, Introduction to the MATLAB environment, Using MATLAB Documentation
Introduction to the course, Operating methodology-Installation Procedure
1. Compare a sample code in C with MATLAB
2. Trajectory of a particle in projectile motion ( solving quadratic equations)
3. Ideal gas law problem to find volume
interfacing matlab with embedded systemsRaghav Shetty
This Book is all about Interfacing Embedded System with Matlab. This book guides the beginners for creating GUI , Modeling with SimuLink & Interfacing Arduino , Raspberry Pi , BeagleBone with Embedded System. This Book is NOT FOR SALE , Only knowledge base for Open Source Community
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
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
bisection method of ppt
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
KEVIN MERCHANT DOCUMENT USEFUL FOR VIEWERS
Computers and Programming , Programming Languages Types, Problem solving, Introduction to the MATLAB environment, Using MATLAB Documentation
Introduction to the course, Operating methodology-Installation Procedure
1. Compare a sample code in C with MATLAB
2. Trajectory of a particle in projectile motion ( solving quadratic equations)
3. Ideal gas law problem to find volume
interfacing matlab with embedded systemsRaghav Shetty
This Book is all about Interfacing Embedded System with Matlab. This book guides the beginners for creating GUI , Modeling with SimuLink & Interfacing Arduino , Raspberry Pi , BeagleBone with Embedded System. This Book is NOT FOR SALE , Only knowledge base for Open Source Community
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
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
2. Introduction to MATLAB
Introduction to MATLAB
Outline:
Outline:
‰ What is Matlab?
‰ What is Matlab?
„ Matlab Screen
V i bl t i i d i
„ Variables, array, matrix, indexing
„ Operators (Arithmetic, relational, logical )
„ Display Facilities
„ Flow Control
Flow Control
„ Using of M-File
„ Writing User Defined Functions
„ Writing User Defined Functions
„ Conclusion
2
3. Introduction to MATLAB
Introduction to MATLAB
What is Matlab?
What is Matlab?
„ Matlab is basically a high level language
y g g g
which has many specialized toolboxes for
making things easier for us
making things easier for us
„ How high?
M l b
Matlab
High Level
Languages such as
g g
C, Pascal etc.
Assembly
3
4. Introduction to MATLAB
Introduction to MATLAB
What are we interested in?
What are we interested in?
„ Matlab is too broad for our purposes in this
„ Matlab is too broad for our purposes in this
course.
„ The features we are going to require is
Matlab
Matlab
Series of
Matlab
d
Command
Line
m-files mat-files
commands
functions Command execution
like DOS command
Input
Data
storage/
like DOS command
window
p
Output
capability
storage/
loading
4
5. Introduction to MATLAB
Introduction to MATLAB
Matlab Screen
Matlab Screen
Command Window
„ Command Window
‰ type commands
„ Current Directory
‰ View folders and m-files
„ Workspace
‰ View program variables
‰ Double click on a variable
to see it in the Array Editor
„ Command History
‰ view past commands
‰ save a whole session
‰ save a whole session
using diary
5
6. Introduction to MATLAB
Introduction to MATLAB
Variables
Variables
„ No need for types i e
„ No need for types. i.e.,
int a;
int a;
double b;
float c;
„ All variables are created with double precision unless
specified and they are matrices.
p y
Example:
>>x=5;
Aft th t t t th i bl 1 1 t i
>>x=5;
>>x1=2;
„ After these statements, the variables are 1x1 matrices
with double precision
6
7. Introduction to MATLAB
Introduction to MATLAB
Array Matrix
Array, Matrix
t
„ a vector x = [1 2 5 1]
x =
1 2 5 1
1 2 5 1
„ a matrix x = [1 2 3; 5 1 4; 3 2 -1]
x =
1 2 3
5 1 4
5 1 4
3 2 -1
„ transpose y x’ y
„ transpose y = x’ y =
1
2
5
5
1
7
8. Introduction to MATLAB
Introduction to MATLAB
Long Array Matrix
Long Array, Matrix
„ t =1:10
t =
t
1 2 3 4 5 6 7 8 9 10
„ k =2:-0.5:-1
k =
2 1 5 1 0 5 0 -0 5 -1
2 1.5 1 0.5 0 0.5 1
„ B = [1:4; 5:8]
x =
1 2 3 4
1 2 3 4
5 6 7 8
8
9. Introduction to MATLAB
Introduction to MATLAB
Generating Vectors from functions
Generating Vectors from functions
„ zeros(M,N) MxN matrix of zeros x = zeros(1 3)
( , ) x = zeros(1,3)
x =
0 0 0
„ ones(M,N) MxN matrix of ones
0 0 0
(1 3)
x = ones(1,3)
x =
„ rand(M,N) MxN matrix of uniformly
di t ib t d d
1 1 1
distributed random
numbers on (0,1)
x = rand(1,3)
x =
0.9501 0.2311 0.6068
9
10. Introduction to MATLAB
Introduction to MATLAB
Matrix Index
Matrix Index
Th t i i di b i f 1 ( t 0 ( i C))
„ The matrix indices begin from 1 (not 0 (as in C))
„ The matrix indices must be positive integer
Given:
Given:
A(-2) A(0)
A( 2), A(0)
Error: ??? Subscript indices must either be real positive integers or logicals.
A(4,2)
Error: ??? Index exceeds matrix dimensions.
10
11. Introduction to MATLAB
Introduction to MATLAB
Concatenation of Matrices
Concatenation of Matrices
„ x = [1 2], y = [4 5], z=[ 0 0]
A = [ x y]
A = [ x y]
1 2 4 5
B = [x ; y]
1 2
4 5
4 5
C = [x y ;z]
C [x y ;z]
Error:
??? Error using ==> vertcat CAT arguments dimensions are not consistent.
11
12. Introduction to MATLAB
Introduction to MATLAB
Operators (arithmetic)
Operators (arithmetic)
+ addition
+ addition
- subtraction
* multiplication
/ division
^ power
power
‘ complex conjugate transpose
12
13. Introduction to MATLAB
Introduction to MATLAB
Matrices Operations
Matrices Operations
Given A and B:
Addition Subtraction Product Transpose
13
14. Introduction to MATLAB
Introduction to MATLAB
Operators (Element by Element)
Operators (Element by Element)
.* element-by-element multiplication
./ element-by-element division
^ element-by-element power
. element-by-element power
14
15. Introduction to MATLAB
Introduction to MATLAB
The use of “ ” – “Element” Operation
The use of . Element Operation
A = [1 2 3; 5 1 4; 3 2 1]
A
A =
1 2 3
5 1 4
3 2 -1
b x * y c x / y d x ^2
y = A(3 ,:)
b = x .* y
b=
c = x . / y
c=
d = x .^2
d=
x = A(1,:)
K ^2
y=
3 4 -1
3 8 -3 0.33 0.5 -3 1 4 9
x=
1 2 3
K= x^2
Erorr:
??? Error using ==> mpower Matrix must be square.
B=x*y
Erorr:
??? Error using ==> mtimes Inner matrix dimensions must agree.
g g
15
16. Introduction to MATLAB
Introduction to MATLAB
Basic Task: Plot the function sin(x)
Basic Task: Plot the function sin(x)
between 0≤x≤4π
„ Create an x-array of 100 samples between 0
and 4π.
and 4π.
„ Calculate sin(.) of the x-array
>>x=linspace(0,4*pi,100);
Calculate sin(.) of the x array
>> i ( ) 0 4
0.6
0.8
1
„ Plot the y-array
>>y=sin(x);
-0.2
0
0.2
0.4
y y
>>plot(y)
0 10 20 30 40 50 60 70 80 90 100
-1
-0.8
-0.6
-0.4
0 10 20 30 40 50 60 70 80 90 100
16
17. Introduction to MATLAB
Introduction to MATLAB
Plot the function e-x/3sin(x) between
Plot the function e sin(x) between
0≤x≤4π
„ Create an x-array of 100 samples between 0
and 4π
and 4π.
>>x=linspace(0,4*pi,100);
„ Calculate sin(.) of the x-array
„ Calculate e-x/3 of the x-array
>>y=sin(x);
„ Calculate e of the x array
>>y1=exp(-x/3);
„ Multiply the arrays y and y1
>> 2 * 1
>>y2=y*y1;
17
18. Introduction to MATLAB
Introduction to MATLAB
Plot the function e-x/3sin(x) between
Plot the function e sin(x) between
0≤x≤4π
„ Multiply the arrays y and y1 correctly
„ Plot the y2-array
>>y2=y.*y1;
„ Plot the y2 array
>>plot(y2) 0.6
0.7
p (y )
0.3
0.4
0.5
0
0.1
0.2
0 10 20 30 40 50 60 70 80 90 100
-0.3
-0.2
-0.1
18
20. Introduction to MATLAB
Introduction to MATLAB
Display Facilities
Display Facilities
„ title(.)
„ xlabel( )
>>title(‘This is the sinus function’)
0.6
0.8
1
This is the sinus function
„ xlabel(.)
>>xlabel(‘x (secs)’)
0
0.2
0.4
0.6
n(x)
„ ylabel(.)
-0.6
-0.4
-0.2
0
sin
>>ylabel(‘sin(x)’)
0 10 20 30 40 50 60 70 80 90 100
-1
-0.8
0.6
x (secs)
( )
20
21. Introduction to MATLAB
Introduction to MATLAB
Operators (relational logical)
Operators (relational, logical)
„ == Equal to
„ ~= Not equal to
„ < Strictly smaller
„ < Strictly smaller
„ > Strictly greater
„ <= Smaller than or equal to
>= Greater than equal to
„ >= Greater than equal to
„ & And operator
p
„ | Or operator
21
23. Introduction to MATLAB
Introduction to MATLAB
Control Structures
Control Structures
Some Dummy Examples
„ If Statement Syntax
Some Dummy Examples
if ((a>3) & (b==5))
if (Condition_1)
Matlab Commands
Some Matlab Commands;
end
Matlab Commands
elseif (Condition_2)
Matlab Commands
if (a<3)
Some Matlab Commands;
elseif (b~=5)
Matlab Commands
elseif (Condition_3)
Matlab Commands
elseif (b 5)
Some Matlab Commands;
end
Matlab Commands
else
Matlab Commands
if (a<3)
Some Matlab Commands;
l
Matlab Commands
end
else
Some Matlab Commands;
end
23
24. Introduction to MATLAB
Introduction to MATLAB
Control Structures
Control Structures
Some Dummy Examples
„ For loop syntax
Some Dummy Examples
for i=1:100
S M tl b C d
for i=Index Array
Some Matlab Commands;
end
for i=Index_Array
Matlab Commands
for j=1:3:200
Some Matlab Commands;
end
end for m=13:-0.2:-21
Some Matlab Commands;
Some Matlab Commands;
end
for k [0 1 0 3 13 12 7 9 3]
for k=[0.1 0.3 -13 12 7 -9.3]
Some Matlab Commands;
end
24
25. Introduction to MATLAB
Introduction to MATLAB
Control Structures
Control Structures
„ While Loop Syntax
while (condition) Dummy Example
while (condition)
Matlab Commands while ((a>3) & (b==5))
Some Matlab Commands;
end
Some Matlab Commands;
end
25
26. Use of M-File
Use of M File
Click to create
Click to create
a new M-File
• Extension “.m”
• A text file containing script or function or program to run
26
27. Introduction to MATLAB
Introduction to MATLAB
Use of M-File
Use of M File Save file as Denem430.m
If you include “;” at the
If you include ; at the
end of each statement,
result will not be shown
immediately
immediately
27
28. Introduction to MATLAB
Introduction to MATLAB
File Input Statements
p
„ Clear memory
„ Clear screen
„ fid = fopen(filename)
„ fid = fopen(filename, permission)
} Argument fid is a file
identifier associated
p ( , p )
„ Statements…..
„ { ……
}
Here opens the file
filename for read
with an open file
„ A = fscanf(fid, format)
filename for read
access
reads data from the file
specified by fid converts it
specified by fid, converts it
according to the specified
format string, and returns it
in matrix A
„ fclose(fid)
28
29. Introduction to MATLAB
Introduction to MATLAB
File Output Statements Here opens the file
„ count = fprintf(fid, format, A, ...)
p p
filename for write access
formats the data in the
real part of matrix A
A conversion specification
controls the notation,
alignment, significant
di it fi ld idth d
digits, field width, and
other aspects of output
format.
29
33. Introduction to MATLAB
Introduction to MATLAB
Writing User Defined Functions
Writing User Defined Functions
„ Functions are m-files which can be executed by
specifying some inputs and supply some desired outputs.
„ The code telling the Matlab that an m-file is actually a
function is
function out1=functionname(in1)
function out1=functionname(in1,in2,in3)
( , , )
function [out1,out2]=functionname(in1,in2)
„ You should write this command at the beginning of the
m-file and you should save the m-file with a file name
m-file and you should save the m-file with a file name
same as the function name
33
34. Introduction to MATLAB
Introduction to MATLAB
Writing User Defined Functions
g
„ Examples
p
‰ Write a function : out=squarer (A, ind)
„ Which takes the square of the input matrix if the input
q p p
indicator is equal to 1
„ And takes the element by element square of the input
t i if th i t i di t i l t 2
matrix if the input indicator is equal to 2
Same Name
34
35. Introduction to MATLAB
Introduction to MATLAB
Writing User Defined Functions
Writing User Defined Functions
„ Another function which takes an input array and returns the sum and product
of its elements as outputs
„ The function sumprod(.) can be called from command window or an m-file as
35
36. Introduction to MATLAB
Introduction to MATLAB
Notes:
Notes:
„ “%” is the neglect sign for Matlab (equaivalent
„ % is the neglect sign for Matlab (equaivalent
of “//” in C). Anything after it on the same line
is neglected by Matlab compiler
is neglected by Matlab compiler.
„ Sometimes slowing down the execution is
g
done deliberately for observation purposes.
You can use the command “pause” for this
You can use the command pause for this
purpose
pause %wait until any key
pause(3) %wait 3 seconds
pause(3) %wait 3 seconds
36
37. Introduction to MATLAB
Introduction to MATLAB
Useful Commands
Useful Commands
„ The two commands used most by Matlab
„ The two commands used most by Matlab
users are
>>help functionname
>>lookfor keyword
37