GNU/Qt Octave Rohin Kumar Y, Dept. of Physics & Astro Physics, University of Delhi.

Slides:



Advertisements
Similar presentations
Lecture 5.
Advertisements

Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Matlab
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
What is MATLAB ? MATrix LABoratory Developed by The Mathworks, Inc ( Mathworks, Inc Interactive, integrated, environment –for.
Introduction to Matlab Tutorial for CS4MN3/SE3X03 Wen Yu McMaster University.
Programming in MATLAB Week 14 – 4/28/09 Kate Musgrave
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
INTRO TO PROGRAMMING Chapter 2. M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files.
MATLAB File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
INTRODUCTION TO MATLAB LAB# 01
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
26 - 3/20/2000AME 150L1 M ATLAB ® /20/2000AME 150L2 M ATLAB ® vs. Fortran Fortran Positives –First Compiler –Legacy Codes –Efficient Numerically.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation TexPoint fonts used in EMF. Read.
Matlab Basics FIN250f: Lecture 3 Spring 2010 Grifths Web Notes.
Introduction to MATLAB. CSPP58001 MATLAB MATLAB is is a matrix-based language well suited for carrying out numerical analysis. It has many, many high-
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Master in Optical Fiber Communications and Photonic Technologies Foundations of Digital Transmission - Fall quarter Introduction to Matlab.
Introduction to Matlab Module #4 Page 1 Introduction to Matlab Module #4 – Programming Topics 1.Programming Basics (fprintf, standard input) 2.Relational.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
BASICS OF MATLAB Engr.Mian Shahzad Iqbal Lecturer,Telecom Department University of Engineering & Technology Taxila.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Matlab & Image processing toolbox Heejune Ahn SeoulTech Last updated Jan.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
Tutorial on Matlab Basics
Introduction to Matlab
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
Matlab review Matlab is a numerical analysis system
MATLAB Tutorial Dr. David W. Graham.
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
How to Use MATLAB A Brief Introduction.
Programming The ideal style of programming is Structured or
Presentation transcript:

GNU/Qt Octave Rohin Kumar Y, Dept. of Physics & Astro Physics, University of Delhi

What is Octave? Octave is an interactive high-level programming language specifically suited for vectorizable numerical calculations. The syntax of Octave resembles that of Matlab. An Octave program usually runs unmodified on Matlab. Matlab, being commercial software, has a larger function set, and so the reverse does not always work (esp. when the program makes use of specialized add-on toolboxes for Matlab) GNU or Qt version? It is FREE!!! Happy Ugadi! :)

Intro The Most important command of octave ''HELP'' :) All commands can be typed in at the prompt or read from a script. Scripts are plain text files with file suffix.m. They are imported by calling the file name without the suffix and behave as if their content was typed in line by line. ';' separates several commands within a line. A command terminated by ';' does not display its result on-screen. ',' separates two commands without suppressing on-screen output. '…' at the end of the line denotes that an expression continues into the next line. Comments are preceded by %. Octave is case sensitive. And don't use filenames same as or similar to available functions

Variables and Standard operations varname = expression assigns the result of expression to varname. Octave has all the usual mathematical functions +, -, *, /, ^, sin, cos, exp, acos, abs, etc. It understands basic constants like pi, e, i etc. The operators of elementary logic are: < smaller <= smaller or equal & and > greater >= greater or equal | or == equal ~= not equal ~ not When debugging user-defined objects, the following commands are useful: 'whos' shows all user-defined variables and functions 'clear name' clears name from memory; if no name is given, all variables and functions will be cleared. (clear all & clc) 'type name' displays information about the variable or function name on the screen.

Input and output 'save data var1 [var2... ]' saves the values of variables var1 etc. into the file data. 'load data' reads the file data, restoring the values of the previously saved variables. blah=input(”Some Message”); 'fprintf(string[,var1,...])' resembles C syntax for formatting output(even printf(”blah\n”) works! 'format [long|short]' enlarges or reduces the number of decimals displayed. Calling format without argument restores the default. ' pause' Suspends evaluation until a key is pressed. 'history n' Shows last n commands 'what', 'pwd', 'cd', 'ls' work as usual 'echo', 'diary file', Data Structures work in a really simple way and functions can return structures

Vectors & Matrices Row Vector, Column Vector A=[1,2,3] B=[1;2;3] General Matrices A=[1,2;3,4] ones(m,n) zeros(m,n) rand(m,n) eye(m,n) diag(V,k) linspace(x1,x2,N) logspace(x1,x2,N)

Basic Matrix Addressing & Operations *,^,.^,.*,+,-,' A(m,n),A(m,:),A(:,n),v(k),v(m:n),length(v),[r,c]= size(A) inv(A), A\b, lu(A), eig(A), [v, d]=eig(A), find(A), any(A), rank(A), roots(v) abs(z), imag(z), real(z), angle(z),conj(z) Lsode for 1st order DE [X, ISTATE, MSG] = lsode (FCN, X_0, T, T_CRIT) Any thing else?

Control Structures Loops, Branching While, for, if-else, switch Break and continue work as usual Global Variables Functions, Functions of Functions

Functions function y = f (x) y = cos(x/2)+x; end function [out1,out2] = dolittle (x) out1 = x^2; out2 = out1*x; end

Functions of Functions function y = gauss(x) y = exp(-x.^2/2); end function S = mpr(fun,a,b,N) h = (b-a)/N; S = h*sum(feval(fun,[a+h/2:h:b])); end mpr('gauss',0,5,500)

File Management fid=fopen(”filename”,”r”) fprintf,fscanf and others can be used as usual Save, load commands with file names to save files fclose(fid) fgets, fputs work in the specified format as their counterparts of C

Graphics! 'plot(x,y[,fmt])' plots a line through the points x,y. With the string fmt you can select line style and color; see help plot for details. 'semilogx(x,y[,fmt])' like plot with a logarithmic scale for the X-axis. 'semilogy(x,y[,fmt])' like plot with a logarithmic scale for the Y-axis. 'loglog(x,y[,fmt])' like plot with a logarithmic scale for both axes. 'title(string)' writes string as title for the graphics. 'xlabel(string)' labels the X-axis with string. 'ylabel(string)' labels the Y-axis with string. 'axis(v)' set axes limits for the plot. v is a vector of form v = (xmin, xmax, ymin, ymax[, zmin zmax]). 'hold [on|off]' controls whether the next graphics output should or not clear the previous graphics. 'clg' clears the graphics window. 'subplot(m,n)' figure(n) creates a new window with no. n

The End