User:JamesJJamesa/sandbox

move to sandbox
''This material represents a rough draft of a first effort on this page. Sections will be deleted when the intent of those sections have been fulfilled.''

first
string0='hello' To run this one-line code follow these three steps:
 * 1) Use notepad-plus-plus to save the code as a text file as myfirstoctave.m (MATLAB extension) and put it where you will find it.  (I use a folder with my name on it for my programs).
 * 2) Use DOS cd and dir commands to find the folder and type the name of that folder (without the extension .m)   MAKE SURE YOUR STATEMENT "string0=hello" DOES NOT HAVE A SEMICOLON AT THE END
 * 3) observe the statement "string=hello" in your command line.

second
% comments begin with the this percent symbol. You don't need one at the end %..... but you need one at the next line. clear all %this erases all prior variables from memory string0='hello' %note the absence of a semicolon; the command window will echo this statement. string1='silent hello';% the semicolon % The semicolon in the second line of this two-line code suppresses the printout on you command line. display('This is how to display something on the command line'); display('This is what happens when you type: whos'); whos;

1. After running this code go into the command line and type the following, one at a time, without a semicolon.

string0

string1

This is one way to learn what variable have been stored in memory.

2. Now type clc. This erases everything from you command window, but keeps the variables in memory. To verify that they remain in memory, type the variables string0 and string1 one at a time.

3. Now type clear and see if string0 and string1 are in memory.

4. Return string0 to memory with a statement like the one in your program.
 * verify that the variable is in memory by typing its name in the command window.
 * What happens if you now capitalize the first letter in the command window by typing String?

5. Type whos at the command window and see what variables you have in memory.

Test
{How are comments declared?} + with a % at the beginning of the sentence to be comment out - with a % at the beginning and the end of the sentence to be commented out - with a ' at the beginning and and the end of the sentence to be commented out - with a ' at the beginning of the sentence to be commented out

{What is the significance of typing ";" at the end of a line?} - Typing ";" prevents the variable from being stored in memory but allows it to appear at the command window. - Typing ";" prevents the variable from being stored in memory and it suppresses from appearing at the command window. + Typing ";" stores the variable in memory but suppresses its appearance at the command window. - Typing ";" permits a comment to follow

{The command that erases everything from the command window is} - clear - clear all + clc - cls

{The command that clears memory is} - clc - cls - %clear + clear - %clc%

{If you continue a sentence into the next line, you must either begin the next line with % (... or perhaps so something else)} + true - false

{Variables in MATLAB/Octave are case-sensitive: Stringname is NOT the same as stringname} + true - false

{Variables are stored and treated differently in memory, depending on whether there were defined with or without the semicolon at the end} - true + false