Physics 114: Final Project Hints

Slides:



Advertisements
Similar presentations
Introduction to MATLAB The language of Technical Computing.
Advertisements

General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
CIS 101: Computer Programming and Problem Solving Lecture 2 Usman Roshan Department of Computer Science NJIT.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
EGR 106 – Week 3 – More on Arrays Brief review of last week Additional ideas: – Special arrays – Changing an array – Some array operators – Character arrays.
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.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Guide to Programming with Python Chapter Two Basic data types, Variables, and Simple I/O: The Useless Trivia Program.
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
05/09/2015SJF L31 F21SF Software Engineering Foundations Formatting Converting numbers to Strings and vice versa Monica Farrow EM G30
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (3): MATLAB Environment (Chapter 1)
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
Introducing Python CS 4320, SPRING Format: Field widths and Alignment The string representation of a value can be padded out to a specific width.
Lecture 28: Mathematical Insight and Engineering.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Intro Python: Variables, Indexing, Numbers, Strings.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
A string is an array of characters Strings have many uses in MATLAB Display text output Specify formatting for plots Input arguments for some functions.
>> x = [ ]; y = 2*x y = Arrays x and y are one dimensional arrays called vectors. In MATLAB all variables are arrays. They allow functions.
Chapter 2 Creating Arrays Legend: MATLAB command or syntax : Blue MATLAB command OUTPUT : LIGHT BLUE.
Array Creation ENGR 1181 MATLAB 2. Civil engineers store seismic data in arrays to analyze plate tectonics as well as fault patterns. These sets of data.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
CMPS 1371 Introduction to Computing for Engineers CHARACTER STRINGS.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
5 February 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
An Introduction to Programming in Matlab Emily Blumenthal
INTRODUCTION TO PROGRAMMING Chapter 2. M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in.
N5 Databases Notes Information Systems Design & Development: Structures and links.
Physics 114: Lecture 1 Overview of Class Intro to MATLAB
Introduction to Programming
Physics 114: Lecture 18 Least Squares Fit to 2D Data
Topics Designing a Program Input, Processing, and Output
EEE 161 Applied Electromagnetics
Release Numbers MATLAB is updated regularly
Physics 114: Lecture 14 Linear Fitting
State Space Representation
Chapter 2 Creating Arrays.
Introduction to Programming for Mechanical Engineers (ME 319)
Variables, Expressions, and IO
Computer Science 3 Hobart College
Other Kinds of Arrays Chapter 11
More C++ Basics October 4, 2017.
2) Platform independent 3) Predefined functions
OPSE 301: Lab13 Data Analysis – Fitting Data to Arbitrary Functions
MATLAB: Structures and File I/O
Physics 114: Exam 2 Review Material from Weeks 7-11
Number and String Operations
Use of Mathematics using Technology (Maltlab)
String Manipulation Chapter 7 Attaway MATLAB 4E.
Physics 114: Lecture 14-a Linear Fitting Using Matlab
Fourth Year – Software Engineering
State Space Analysis UNIT-V.
Array Creation ENGR 1181 MATLAB 02.
INTRODUCTION TO MATLAB
Islamic University of Gaza
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
User Input Keyboard input.
Text Manipulation Chapter 7 Attaway MATLAB 5E.
Presentation transcript:

Physics 114: Final Project Hints John Federici NJIT Physics Department

TRIVIA QUESTION! What day of the year is usually celebrated by fans as ‘Star Wars Day’? (a) January 1 (b) March 20 (c) April 15 (d) May 4 (e) May 14

TRIVIA QUESTION! What day of the year is usually celebrated by fans as ‘Star Wars Day’? (a) January 1 – ‘A New Hope’ (b) March 20 – first day of Spring – ‘The Force Awakens’ (c) April 15 – Income Taxes due – ‘ The Empire Strikes Back’ (d) May 4 – ‘May the fourth be with you’ (e) May 14 – George Lucas Birthday

Text data Define a STRING by putting alphanumeric characters in ‘quotes’ >> year=2017; >> DateString='The year is '; >> TempString=[DateString,int2str(year),'. HAPPY NEW YEAR!']; >> disp(TempString) The year is 2017. HAPPY NEW YEAR! >> As you would expect, there is standard syntax to concatenate strings and to convert numeric data (eg. int2str, num2str, sprintf) to string data. Display a STRING with ‘disp’ NOTE: Some functions interpret a ‘FORMAT SPECIFIER Differently…

Text data - continued NOTE: Some functions interpret a ‘FORMAT SPECIFIER Differently… >> i=5; >> str1=int2str(i) str1 = 5 >> str2=num2str(i,'%3d') str2 = >> str3=sprintf('%3d',i) str3 = >> NOTE: for sprintf function, spaces PAD on the left to ensure that the string is 3 characters long while for num2str, the same format string DOES NOT PRODUCE SAME RESULTS

Array quirks Sometimes you will get an ERROR in matlab if the sizes of matrices do not match in a mathematical operation. For example if A is a 1 by N matrix and B is an N by 1 matrix, math operations such as multiplication and division will give errors. A trick is to TRANSPOSE one of the matrices. For example BT=transpose(B) Will convert B as a N by 1 matrix to a 1 by N matrix.

Programatically Saving Best Fit Parameters In order to create an image of your best fit variable, you can use the following code: [fitresult, gof] = fit( xData, yData, ft, opts ); myImage(x,y)=fitresult.nr; The first line of code using the ‘fit’ function to fit the xData and the yData to the fit type defined by ‘ft’ with the options (eg. excluded points, starting values etc.) defined by ‘opts’. You can use the online help for more details and examples. The output variable ‘fitresult’ contains the results of the fits. Assuming that the real refractive index variable in the best fit is called ‘nr’, then the variable ‘fitresult.nr’ is the best fit value for the real refractive index.

Programatically Saving Best Fit Parameters You can use the ‘confint’ command to report the confidence intervals (95%) for the best fit parameters: >> confint(fitresult)   ans = -0.0739 1.5665 -0.0608 1.6144 Remember that in the sciences (and Physics), one usually describes error using 1 standard deviation (65% confidence level).

Reminder on using Histogram Recall that the ‘histogram’ function ASSUMES that the data is a 1D vector. So that if you want a histogram of the 2D image data all together, you need to convert the 2D matrix of data into a 1D vector of data. To accomplish this, use the ‘reshape’ function.