CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.

Slides:



Advertisements
Similar presentations
Elements 1-10.
Advertisements

Elements - Names and Symbols n Hydrogen nHnH n Helium n He n Lithium n Li.
Lecture 1.1 Refresh your high school chemistry CS882, Fall 2006.
Hund’s Rule, Orbital Diagrams, and Valence Electrons
Computer Science 121 Scientific Computing Winter 2012 Chapter 5 Files and Scripts.
Sodium (Na) - 11 Atomic Number = - - Atomic Mass = neutrons
More Summary Statistics March 5, 2013 CS Intro. to Comp. for the Humanities and Social Sciences 1.
Introduction to ATOMS. Electrons are always on the move.
Atoms and Elements. Atoms Atoms are the “building blocks” of all matter and are the simplest form of molecule. They are all made up of protons, neutrons.
Periodic Table of Elements. Element An element is a substance that is made up of ONE kind of atom only. e.g. Carbon.
08/09/2015 Starter - Elements and symbols that you should know: Part 1 – The obvious ones: 1)Hydrogen 2)Helium 3)Lithium 4)Beryllium 5)Boron 6)Carbon 7)Nitrogen.
Atomic structure.
PRACTICE DRAWING ATOMS. DRAWING ATOMS RULES PROTONS = Atomic number ELECTRONS = Atomic number NEUTRONS = mass number – atomic number 1 st level can hold.
Daniel R. Barnes Init:10/2/ look at a drawing of an atom and determine its element, its atomic number, its mass number, and its electric charge.
Question 1 How many different groups are there on the periodic table?
Elements and Symbols Practice. PART I (SLIDES WITH BLUE BACKGROUNDS) Directions: Name the Symbol for each listed element.
Atomic Structure. Rules Of Atomic Structure 1.The Number of electrons = number of protons 2.Atomic Number = the number of protons/electrons 3.Atomic Mass.
# of valence electrons = 1 P: 3 N: P+: 3 e-: 3 N: 4 Let’s do together:
18 Bohr Models Lesson 3.1 Extension. Element Name: _______________________ Chemical Symbol: _______Atomic Number: _______ Diagram the Bohr atom which.
The Chemistry of Life Section 2.1: The Nature of Matter Teacher: Mrs. Rolle Presenter: Mevan Siriwardane September 27, 2007.
Bohr Model Diagrams Lesson 3.1 Extension.
CHEMISTRY PART 1 Atoms and The Periodic Table. Definitions  Chemistry:  The study of the structure and properties of matter.  Element:  A substance.
Periodic Table of the Elements. Select an element = Internet link ()
hydrogen atom 1 atomic number so one electron 1 H X.
DNA molecule EXAMPLE: CARBON AND ITS ISOTOPES CHEMICAL ELEMENTS & ISOTOPES CARBON = C (COAL, DIAMOND) C-22 6P+16N T½=9ms M= C-9 6P+3N T½=127ms M=9.031.
CS112 Scientific Computation Department of Computer Science Wellesley College Storing it away for safe keeping Reading and writing text files.
Review of Elements #1-20 Good Luck!! FabulousFunFriskyDr. Evil
Put a different element name on each card, along with its symbol, number of protons and number of electrons. Metals on 1 colour, others on other What makes.
Atomic Structure.
La Tabla Periodica Cada elemento Y su explicacion.
Name That Element Extra Credit Created by T.Trimpe 2008.
Ion Formation 1. Proton p + +1 Electron e- -1 Neutron n 0 0 Neutrons are not contributors to charge Exception: nuclear decay Neutral atom has same number.
Copyright 2011 CreativeChemistryLessons.comCreativeChemistryLessons.com O Oxygen Atomic # 8 Atomic Mass 16 8 Protons 8 Neutrons 8 Electrons O
Interpreting the Periodic Table H He LiBeBCNOFNe NaMg KCa AlSiPSClAr
Atomic number = number of protons # protons = # electrons IN NEUTRAL ATOMS.
Today in Physical Science 
Atomic Structure. It used to be thought that atoms were small indivisible particles. It was thought that the only difference between the atoms of one.
First 20 Elements in the Periodic Table
Hydrogen H 1 1 Atomic number = 1 Mass number = 1
Bohr Models in P.T..
ELECTRONS AVAILABLE FOR BONDING
STARTER Complete the word wheel. Write the keywords in a short paragraph but they must be in the order of the word wheel. Electrons Atomic Mass Protons.
19/09/2018 Atoms and Elements W Richards Worthing High School.
19/09/2018 Atoms and Elements.
19/09/2018 Atoms and Elements.
Do these steps on the front of the worksheet
Periodic Table Element flashcards
Atomic structure All material is made up of tiny particles called atoms. Atoms are extremely small particles. The head of a pin contains about
Using abstraction make tiny particles come to life
Orbital Diagrams
Move and label the protons, neutrons, and electrons to build an atom of each of the following elements.
Atom Model Using Periodic Table Boxes
A-Maze-ing Elements Start Exit Don’t touch black blocks!
Elements numbers 1-20.
BELL WORK! Pick up a handout and glue it in your composition notebook on page 64. Quietly work on the handout.
Build An Atom Workshop: Hydrogen 1
Unit 2 Chemical Categories.
Atomic Structure.
ELECTRONS AVAILABLE FOR BONDING
ELECTRONS AVAILABLE FOR BONDING
Atom Identification Daniel R. Barnes Init:10/2/09.
Element Quiz 2 Study Guide
Objectives Know how to use the periodic table to determine the number of electrons available for bonding. Know how to draw Lewis dot structures.
17/05/2019 Atoms and Elements W Richards Worthing High School.
Isotopes & Ions.
Section 2.1: The Nature of Matter Adapted from Teacher: Mrs. Rolle
Electron Configuration
SQL.
Table 2-1.
List the elements or their symbols Give their atomic number
Presentation transcript:

CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING

Reading a text file into a cell array Information can be stored in text files, with a.txt extension mobydick.txt: Call me Ishmael. Some years ago – never mind how long precisely – having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation… fid = fopen('mobydick.txt'); words = textscan(fid, '%s'); fclose(fid); fid = fopen('mobydick.txt'); lines = textscan(fid, '%s', 'delimiter', '\n'); fclose(fid)

Reading formatted text with textscan Suppose we have a text file elements.txt that contains a mix of numerical data and strings, in a fixed format 1 hydrogen H helium He lithium Li beryllium Be boron B carbon C nitrogen N oxygen O fluorine F neon Ne 20.18

Reading formatted data fid = fopen( ' elements.txt'); ! elements = textscan(fid, ' %u %s %s %f ' ); fclose(fid);

vice versa: Writing formatted data >> atomNums = [ …]; >> names = {'hydrogen' 'helium‘ 'lithium' 'beryllium' …}; >> symbols = {'H' 'He' 'Li' 'Be' …}; >> masses =[ …];

Formatting strings with sprintf >> sprintf( '%u %s %s %f', atomNums(1), names{1}, symbols{1}, masses(1)) for i = 1:4 disp(sprintf(’%u %s %s %f', atomNums(i), names{i}, symbols{i}, masses(i))) end

Writing data to a text file (1) Open file for writing (2) Write text to file (3) Close file fid = fopen('elements.txt', 'w') ; for i = 1:length(atomNums) fprintf(fid, '%4u %12s %4s %8.2f \n', atomNums(i), … names{i}, symbols{i}, masses(i)); end fclose(fid);

Writing files with literal strings data = {{'mary' } … {'karen' } … {'betty' } … … }; fid = fopen('cs112.txt', 'w'); fprintf(fid, ‘Data for CS112 assignment work \nSpring 2010 \n\n'); for i = 1:length(data) fprintf(fid,... \n',... data{i}{1}, data{i}{2}, data{i}{3}, data{i}{4}); end fclose(fid);

Your turn! How can we read an Excel file with Matlab?? Find the function, read the help, then use on the next lab exercise!

QUESTIONS??

Resources Lecture slides CS112, Ellen Hildreth,