Skip to content

update to newest Cooper fork #2

Merged
merged 32 commits into from
Feb 16, 2017
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e5b6204
added lecture_05
rcc02007 Jan 26, 2017
e44a490
added lecture_05
rcc02007 Jan 26, 2017
af7ae19
added HW 2
rcc02007 Jan 27, 2017
7696985
format HW2
rcc02007 Jan 27, 2017
7f93380
fix typo in HW2
rcc02007 Jan 27, 2017
a498831
add HW2 figure
rcc02007 Jan 28, 2017
9cff604
Merge branch 'master' of https://github.uconn.edu/rcc02007/ME3255S2017
rcc02007 Jan 28, 2017
490943d
add HW2 figure png
rcc02007 Jan 28, 2017
0156322
add HW2 figure png
rcc02007 Jan 28, 2017
f8b20da
Update README.md
rcc02007 Jan 28, 2017
ae2b934
Update syllabus tools used
rcc02007 Jan 28, 2017
436a6ba
Update syllabus tools used and format
rcc02007 Jan 28, 2017
ab77768
Add matlab link
rcc02007 Jan 28, 2017
517b20c
Add links for octave and github
rcc02007 Jan 28, 2017
561666b
Peiyu's office hour is updated.
pez16103 Jan 30, 2017
67cefad
updated lecture 05
rcc02007 Jan 31, 2017
db85c52
Merge branch 'master' of https://github.uconn.edu/rcc02007/ME3255S2017
rcc02007 Jan 31, 2017
908bbf1
updated lecture 06
rcc02007 Feb 2, 2017
2ce5ca3
updated lecture 07
rcc02007 Feb 7, 2017
1282935
updated lecture 07 output
rcc02007 Feb 7, 2017
3bfd22a
updated lecture 07 pdf and markdown
rcc02007 Feb 7, 2017
3519f1b
added HW3
rcc02007 Feb 8, 2017
6e10962
added HW3
rcc02007 Feb 8, 2017
889acf4
update HW3
rcc02007 Feb 13, 2017
4b1d857
update HW3
rcc02007 Feb 13, 2017
593b1de
updated HW3 1d
rcc02007 Feb 13, 2017
59658f7
Delete �Y
rcc02007 Feb 13, 2017
e5f170b
Delete �40
rcc02007 Feb 13, 2017
5128cfd
update lecture 08
rcc02007 Feb 14, 2017
9e7d607
Merge branch 'master' of https://github.uconn.edu/rcc02007/ME3255S2017
rcc02007 Feb 14, 2017
c994d71
format lecture_08.pdf
rcc02007 Feb 14, 2017
4c0d2a9
update syllabus
rcc02007 Feb 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added lecture_05
rcc02007 committed Jan 26, 2017
commit e5b6204f74057db169d098c86d55df9a8a823b65
6 changes: 6 additions & 0 deletions lecture_05/.ipynb_checkpoints/lecture_05-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
208 changes: 208 additions & 0 deletions lecture_05/lecture_05.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Good coding habits\n",
"## naming folders and files"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Stanford file naming best practices](https://library.stanford.edu/research/data-management-services/data-best-practices/best-practices-file-naming)\n",
"\n",
"1. Include information to distinguish file name e.g. project name, objective of function, name/initials, type of data, conditions, version of file, \n",
"2. if using dates, use YYYYMMDD, so the computer organizes by year, then month, then day\n",
"3. avoid special characters e.g. !, #, \\$, ...\n",
"4. avoid using spaces if not necessary, some programs consider a space as a break in code use dashes `-` or underscores `_` or CamelCase"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Commenting your code"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Its important to comment your code to mention what a variable's units are, what the function is supposed to do, etc. \n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"function i=code(j)\n",
" % Example of bad variable names and bad function name\n",
" for w=1:j\n",
" i(w)=w;\n",
" end\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'code' is a command-line function\n",
"\n",
" Example of bad variable names and bad function name\n",
"\n",
"\n",
"Additional help for built-in functions and operators is\n",
"available in the online version of the manual. Use the command\n",
"'doc <topic>' to search the manual index.\n",
"\n",
"Help and information about Octave is also available on the WWW\n",
"at http://www.octave.org and via the help@octave.org\n",
"mailing list.\n"
]
}
],
"source": [
"help code"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Choose variable names that describe the variable"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"function count_vector=counting_function(max_value)\n",
" % Good variable names and better help documentation\n",
" % \n",
" % counting function creates a vector from 1 to max_value where each index, i, is \n",
" % stored in each vector spot\n",
" for i=1:max_value\n",
" count_vector(i)=i; % set each element in count_vector to i\n",
" end\n",
"end "
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"'counting_function' is a command-line function\n",
"\n",
" Good variable names and better help documentation\n",
" \n",
" counting function creates a vector from 1 to max_value where each index, i, is \n",
" stored in each vector spot\n",
"\n",
"\n",
"Additional help for built-in functions and operators is\n",
"available in the online version of the manual. Use the command\n",
"'doc <topic>' to search the manual index.\n",
"\n",
"Help and information about Octave is also available on the WWW\n",
"at http://www.octave.org and via the help@octave.org\n",
"mailing list.\n"
]
}
],
"source": [
"help counting_function"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"## Putting it all together"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. Clone your homework_1 to your computer\n",
"2. open Matlab (cli, jupyter or gui)\n",
"3. Change working directory to homework_1 *e.g.* Windows:`cd('C:\\Users\\rcc02007\\Documents\\Github\\homework_1')`, Mac: `cd('/Users/rcc02007/Documents/Github/homework_1')`\n",
"4. You have already created your first script `myscript.m` (if not see lecture_4)\n",
"5. Run `>> my_script.m`\n",
"6. Create a new m-file called nitrogen_pressure.m\n",
"7. Create a function based upon the ideal gas law for nitrogen, Pv=RT\n",
" 1. R=0.2968 kJ/(kg-K)\n",
" 2. inputs to function are v (specific volume m^3/kg), and T, temperature (K)\n",
" 3. output is P, pressure (kPa)\n",
"8. Once the function works, commit the change to the repository (add a message, like 'added file nitrogen_pressure.m'\n",
"9. After file is 'committed', 'push' the changes to your github account\n",
"\n",
"for the command-line git user, this is steps 8 and 9:\n",
"1. `$ git add *`\n",
"2. `$ git commit -m 'added file nitrogen_pressure.m'`\n",
"3. `$ git push -u origin master\n",
" Username for 'https://github.uconn.edu':rcc02007 <enter>\n",
" Password for 'https://rcc02007@github.uconn.edu': `\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Octave",
"language": "octave",
"name": "octave"
},
"language_info": {
"file_extension": ".m",
"help_links": [
{
"text": "MetaKernel Magics",
"url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
}
],
"mimetype": "text/x-octave",
"name": "octave",
"version": "0.19.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
109 changes: 109 additions & 0 deletions lecture_05/lecture_05.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

# Good coding habits
## naming folders and files

[Stanford file naming best practices](https://library.stanford.edu/research/data-management-services/data-best-practices/best-practices-file-naming)

1. Include information to distinguish file name e.g. project name, objective of function, name/initials, type of data, conditions, version of file,
2. if using dates, use YYYYMMDD, so the computer organizes by year, then month, then day
3. avoid special characters e.g. !, #, \$, ...
4. avoid using spaces if not necessary, some programs consider a space as a break in code use dashes `-` or underscores `_` or CamelCase

## Commenting your code

Its important to comment your code to mention what a variable's units are, what the function is supposed to do, etc.



```octave
function i=code(j)
% Example of bad variable names and bad function name
for w=1:j
i(w)=w;
end
end
```


```octave
help code
```

'code' is a command-line function

Example of bad variable names and bad function name


Additional help for built-in functions and operators is
available in the online version of the manual. Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.


## Choose variable names that describe the variable


```octave
function count_vector=counting_function(max_value)
% Good variable names and better help documentation
%
% counting function creates a vector from 1 to max_value where each index, i, is
% stored in each vector spot
for i=1:max_value
count_vector(i)=i; % set each element in count_vector to i
end
end
```


```octave
help counting_function
```

'counting_function' is a command-line function

Good variable names and better help documentation
counting function creates a vector from 1 to max_value where each index, i, is
stored in each vector spot


Additional help for built-in functions and operators is
available in the online version of the manual. Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.


## Putting it all together

1. Clone your homework_1 to your computer
2. open Matlab (cli, jupyter or gui)
3. Change working directory to homework_1 *e.g.* Windows:`cd('C:\Users\rcc02007\Documents\Github\homework_1')`, Mac: `cd('/Users/rcc02007/Documents/Github/homework_1')`
4. You have already created your first script `myscript.m` (if not see lecture_4)
5. Run `>> my_script.m`
6. Create a new m-file called nitrogen_pressure.m
7. Create a function based upon the ideal gas law for nitrogen, Pv=RT
1. R=0.2968 kJ/(kg-K)
2. inputs to function are v (specific volume m^3/kg), and T, temperature (K)
3. output is P, pressure (kPa)
8. Once the function works, commit the change to the repository (add a message, like 'added file nitrogen_pressure.m'
9. After file is 'committed', 'push' the changes to your github account

for the command-line git user, this is steps 8 and 9:
1. `$ git add *`
2. `$ git commit -m 'added file nitrogen_pressure.m'`
3. `$ git push -u origin master
Username for 'https://github.uconn.edu':rcc02007 <enter>
`



```octave
```
Binary file added lecture_05/lecture_05.pdf
Binary file not shown.
Binary file added lecture_05/octave-workspace
Binary file not shown.