Timing
In some cases there could be limitations of time. How long a certain calculation are supposed to continue and therefore Matlab provides us with a tool to find out what parts of a program that are time-consuming. This is accomplished by the command profile.
Let us have a look on our previously used m-file nonsens. Write!
profile on % starts timer
nonsens
profile off
profile report % Opens a html-page, where you can find a table.
% Click on the link nonsens.
% Consumed time for each command line are shown.
Logical operators
& Logical and
| Logical or
~ Logical not
Finally we will look on three examples to see how we can use these operators.
% Logical AND
x=input('Give a x: ')
k=input('Give a k: ')
if x==3&k<100 % if x=3 and k<100, then display ”Hello !”
disp('Hello !')
else
disp('Hi !') % otherwise display ”Hi !”
end
% Logical OR
x=input('Give a x: ')
k=input('Give a k: ')
if x==3|k<100 % if x=3 or k<100, then display ”Hello !”
disp('Hello !')
else
disp('Hi !') % otherwise display ”Hi !”
end
% Logical NOT
k=input('Give a k: ')
if ~(k<100) % if k>=100, then display ”Hello !”
disp('Hello !')
else % otherwise display ”Hi !”
disp('Hi !')
end
Related posts:
- Matlab Tutorial 3: Strings in Matlab
- Matlab Tutorial 2: Matrices in Matlab
- Matlab Tutorial 4: Data Analysis and Statistics with Matlab
- Matlab Tutorial 1: Hello world, plotting, mathematical functions and file types
Pages: 1 2 3 4
Tags: Debugging in matlab, debugging tutorial for matlab, debugging tutorial in matlab, For loop, For loop example for matlab, For loop in matlab, how debug works in matlab, how to debug in matlab, If-else example, If-else example for matlab, If-else example in matlab, If-else in matlab, If-else sample in matlab, Interrupt commands, Interrupt commands example in matlab, Interrupt commands for matlab, Interrupt commands in matlab, interrupt example in matlab, logical operators, logical operators example for matlab, logical operators for matlab, logical operators in matlab, logical operators samle code for matlab, matlab codes, matlab courses, matlab examples, matlab try catch, matlab try catch example, matlab tutorial, Matlab Tutorials, Nested loop example for matlab, Nested loop sample code for matlab, Nested loops example code for matlab, Nested loops in matlab, Nested loops sample in matlab, Switch example for matlab, Switch example in matlab, Switch for matlab, Switch in matlab, Switch sample code for matlab, timing in matlab, try and catch example for matlab, Try-catch matlab, Try-catch-end example, Try-catch-end example for matlab, Try-catch-end matlab, While, while in matlab, while loop example for matlab, While loop in matlab
Print This Post
Matlab Tutorials | admin, July 5, 2010 8:47 am