Thursday, October 15, 2015

Lecture for October 15

So Once again we decide to use functions that are not available to those who use the computers that are provided in class (namely me). Therefore a written commentary of today's lesson will be littering my blogger post.

First and foremost let us explain the Function ezplot(). This function will plot an equation from -2pi to 2pi which gives a smooth curved line and will the title an expression of ezplot. If you wanted to change the x range of the graph, the second input to the function will represent that. ex :
ezplot(y,[range])
using the title/xlable/ylable functions is the same as using normal graphing. A variable representation of an equation is not necessary the equation can be the first input if desired how ever it must be written in the the constraints of apostrophes . Default from trigonometric function with the syntax of t has a different specific axis range. Must use hold on command to have multiple lines on the same graph instead of graphing different equations in the same line of code as an error occurs.
this is a table that represents the functions that you can use for ezplot:
Symbolic Plotting Functions
ezplot
Function plotter
If z is a function of x : ezplot(z)
ezmesh
Mesh plotter
If z is a function of x and y : ezmesh(z)
ezmeschc
Combined mesh and contour plotter
If z is a function of x and y : ezmeshc(z)
ezsurf
Surface plotter
If z is a function of x and y : ezsurf(z)
ezsurfc
Combined Surface and contour plotter
If z is a function of x and y : ezsurfc(z)
ezcontour
Contour plotter
f z is a function of x and y : ezcontour(z)
ezcontourf
Filled contour plotter
If z is a function of x and y : ezcontourf(z)
ezplot3
Three-dimensional parametric curve
plotter
If x is a function of t , if y is a function of t , and if
z is a function of t : ezplot3(x,y,z)
ezpolar
Polar coordinate plotter
If r is a function of u : ezpolar(r)

Making these graphs are much easier than trying to make the same plots using the plot functions.These functions can also handle parametered functions as well
Using this mathematical model we solve and graph the same ballistics problem with the ezplot function. to solve the maximum angle that would get the largest range, the derivative with respect to theta would be calculated and then solved for the equation equal to zero. Afterward That theta value would be plugged back in to the initial equation using the sub function to find out what the max range is.

In this particular moment I feel inadequate in my attempt to understand the material being discussed as I can only contemplate theoretical answers and had some trouble shooting incursion occurred I am not entirely convinced that I'd be able to reach some sort of end that would meet the requirements to the parameters of the particular coding I  intend on doing. There is also the vast emptiness that is felt while others are doing examples and I am just merely commenting on the lesson as we progress.

From here we move to calculus equations and thought patterns. the function for derivative would be diff() which stands for differentials that has the same meaning as derivatives. You can do the degrees of differentials by placing the input without apostrophes to have a differential with respect to a certain variable it is the second input in apostrophes .

As far as the integration concept is applied to matlab, the function int is used and much the same way that diff is used you can nest integrals or integrate with respect to a certain variable. Matlab also allows for definite integrals. for this specific code you set a variable equal to the integration and use the difference sub functions from the integration values. Don't forget to reformat answers to doubles to use them for future use in regular functions. definite integration can also be set to variable points that are arrays. the matlabFunction() converts functions to anonymous functions which act like normal matlab functions.

Tuesday, October 13, 2015

lecture october 13

Remember to enter strings in single quotes
Enter a planet name in single quotes:Enter the mass in multiples of earth's mass: 'mercury'
Enter the length of the planetary year in Earth years: 0.055
Enter the mean orbital velocity in km/sec: 0.24

ans =

        name: []
        mass: 'mercury'
        year: 0.0550
    velocity: 0.2400

Remember to enter strings in single quotes
Enter a planet name in single quotes:'mercury'
Enter the mass in multiples of earth's mass: 0.055
Enter the length of the planetary year in Earth years: 0.24
Enter the mean orbital velocity in km/sec: 47.89

ans =

        name: 'mercury'
        mass: 0.0550
        year: 0.2400
    velocity: 47.8900

Remember to enter strings in single quotes
Enter a planet name in single quotes:'venus'
Enter the mass in multiples of earth's mass: 0.815
Enter the length of the planetary year in Earth years: 0.62
Enter the mean orbital velocity in km/sec: 35.02

ans =

        name: 'venus'
        mass: 0.8150
        year: 0.6200
    velocity: 35.0200

Remember to enter strings in single quotes
Enter a planet name in single quotes:'earth'
Enter the mass in multiples of earth's mass: 1
Enter the length of the planetary year in Earth years: 1
Enter the mean orbital velocity in km/sec: 29.79

ans =

        name: 'earth'
        mass: 1
        year: 1
    velocity: 29.7900

Remember to enter strings in single quotes
Enter a planet name in single quotes:'mars'
Enter the mass in multiples of earth's mass: 0.107
Enter the length of the planetary year in Earth years: 1.88
Enter the mean orbital velocity in km/sec: 24.12

ans =

        name: 'mars'
        mass: 0.1070
        year: 1.8800
    velocity: 24.1200

Remember to enter strings in single quotes
Enter a planet name in single quotes:'jupiter'
Enter the mass in multiples of earth's mass: 318
Enter the length of the planetary year in Earth years: 11.86
Enter the mean orbital velocity in km/sec: 13.06

ans =

        name: 'jupiter'
        mass: 318
        year: 11.8600
    velocity: 13.0600

Remember to enter strings in single quotes
Enter a planet name in single quotes:'saturn'
Enter the mass in multiples of earth's mass: 95
Enter the length of the planetary year in Earth years: 29.46
Enter the mean orbital velocity in km/sec: 9.64

ans =

        name: 'saturn'
        mass: 95
        year: 29.4600
    velocity: 9.6400

Remember to enter strings in single quotes
Enter a planet name in single quotes:'uranus'
Enter the mass in multiples of earth's mass: 15
Enter the length of the planetary year in Earth years: 84.01
Enter the mean orbital velocity in km/sec: 6.81

ans =

        name: 'uranus'
        mass: 15
        year: 84.0100
    velocity: 6.8100

Remember to enter strings in single quotes
Enter a planet name in single quotes:'neptune'
Enter the mass in multiples of earth's mass: 17
Enter the length of the planetary year in Earth years: 164.8
Enter the mean orbital velocity in km/sec: 5.43

ans =

        name: 'neptune'
        mass: 17
        year: 164.8000
    velocity: 5.4300

Remember to enter strings in single quotes
Enter a planet name in single quotes:'pluto'
Enter the mass in multiples of earth's mass: 000.002
Enter the length of the planetary year in Earth years: 247.7
Enter the mean orbital velocity in km/sec: 4.74

ans =

        name: 'pluto'
        mass: 0.0020
        year: 247.7000
    velocity: 4.7400


planetary =

1x9 struct array with fields:

    name
    mass
    year
    velocity

>> planetary.name

ans =

mercury


ans =

venus


ans =

earth


ans =

mars


ans =

jupiter


ans =

saturn


ans =

uranus


ans =

neptune


ans =

pluto

>> nameas=[planetary.name];
>> nameas=char(planetary.name);
>> struct2table(planetary)

ans =

      name       mass     year     velocity
    _________    _____    _____    ________

    'mercury'    0.055     0.24    47.89  
    'venus'      0.815     0.62    35.02  
    'earth'          1        1    29.79  
    'mars'       0.107     1.88    24.12  
    'jupiter'      318    11.86    13.06  
    'saturn'        95    29.46     9.64  
    'uranus'        15    84.01     6.81  
    'neptune'       17    164.8     5.43  
    'pluto'      0.002    247.7     4.74  

>> mean(planetary.velocity)
Error using mean
Too many input arguments.

this is the code that goes with the planetary homework/lecture question with everything but the average speed working. So it was basically just getting a better handle on structures which is kewl.

For some part of the class the notes were on symbolic functions which, using the schools mandated matlab program, was not available to me so... anyway this stuff is pretty nifty, like having a variable equal to another variable that is a symbol makes the initial variable a symbolic matrix. one can also define the symbols that are used in a equation and then run that equation. Basically the computer does all the work and the user just has to remember to format correctly.
avoid these symbol names:
D,E,I,O,beta,zeta,theta,psi,gamma,Ci,Si,Ei
they are already used as either functions or specific variables in matlab and you would have to clear the work space to get that variable back. might be great to not clear the workspace for today.


Apparently the values of symbols in the equations are just there for visual effect and a function is required to replace certain symbols with their values given by the user. At this point in time everyone else is doing examples and writing exercises and equations based off of symbols: x,a,b,c,d that were created at the beginning. ten of each exercise and equation, but we can just copy and paste so it doesnt  take much time at all.

the numden function is pretty great, it gives a numerator and denomonator for what symbol you want to know though the function does not work in the way that was intended to simplify but only if it simplifies to easily. Had the equation been difficult to simplify the desired results appears. You may also use different mathmatic operation systems for num den, there is also an expand and factor func for these two. collect function should work for all, despite equations or expressions. actually collect requires an expression.

next subject is MuPAD, it's like having a maple window in matlab though your computer might not run it if maple is already on your hardrive.

much as the name would suggest, the simplify function simplifies the equation

you can make a vector in to a poly equation and from there make it a sym using poly2sym and sym2poly functions, keep an eye on workspace to see if there is anything weird in the size.

so to solve for the function you would use a combination of the solve and/or the sub functions. solve sets it to solve the equation equal to zero unless a second element is added. if the variables are defined as symbols then " ' " are not necessary. MuPAD only recognizes ints and floating points, accurate with floating point up to 32 places. if you solve for a specific symbol place the variable in single quotations. When you solve a system of equations using solve the answers are put into a structure. By inputting answer.variable the answer will print.
this is an upside down hand example that we would input in matlab to solve for a specific variable from an equation.

When working with a nonlinear system, well you dont  work with nonlinear equations. Who are you trying to impress? We are not mapping theoretical physics for the fifth dimension. All engineering can be based off models of linear equations.
To use the subs function, the equation is called first then the object that is wished to be subbed, finally the new value in place of the subbed value.

Homework number 11

 This is question one, as it says in the last comment the differences between the two variables is given in the work space.
 This is question two, if you were to follow the commenting break up you will get the answer to each part of the question in the command window or in the  workspace window.
 question 3 with an immature example on how to encode. option to not encode are not given because why would you respond to an input prompt that asks to write a message to encode and not want to encode that message.
 this is question 4 where I forgot to input the values for neptune. Anyway since it requires user input a while loop was used to make writing the code shorter. It was previously set into an array but then set up as  a structure as per requested
 this is just the code that sets up the next answer
now here is the last question and it is the only thing displayed despite me displaying everything to use a new function and to prove that the previous code was working, not that it wouldnt work because the program could not proceed if it didnt work in the earlier stages.

Thursday, October 8, 2015

HomeWork 10

Questions one and 2 for Homework 10. specifically for the time usage on question one the '\' function was quicker but the time could be negligible. for question 2 the flow was 33.3 and 66.67 from top and bottom respectively.

This is question three, it was the same exact problem as the one one done in lecture with different angles of the triangle and applied force

Tuesday, October 6, 2015

Undated lecture notes

3d model of a sphere using cool colors (not the name of the color spectrum)

working with graphing 

the first time we learned how to do original functions, sucks that it cant be in the original code and has to be written in a seperate mscript and included in that folder that the program runs off.

another one...

meshgrid function, and some more plotting functions. meshgrid became super important later on to do some other functions and then not so important with the introduction of others.
more graph stuff *yawn*


I forgot what surf and mesh functions did
and finally a practical problem that compares graphs  on the same figure window yay!




what ever this is getting frustrating trying to write this in the right format. the above is a program that deals with imaginary numbers and the following is the output of that code




this picture represents the  overview of polar in matlab
bringing a table from excel into matlab to work with the numbers from that table
doing standard deviation I suppose.

sorting functions. here I was using the f9 macro key to run the section of code, its easier than clicking run section under the editor tab
doing more functions with lists, mean median mode stuff.
answers to some code that was written maybe further down in the blog...
I guess not this is just some physics problem with user input and message output.

White board photos, no dates, no order, just chaos










Lecture 2



first time using the mscript window to create programs that can be used later on. did an example with air drag and putit into a table.
so making a table of dialoug output that shows the values of a table created.
working with user input with a physics program
having some issues with fprintf and a table

lecture for October 6

to see commentary on lecture see comments in code picture

Home Work 9

I really do wish there was a way to upload the code directly to blogger instead of screen printing each piece form the script window
these are questions 1-3 all simple though I had to do some tweaking with 2 to make sure the mtimes function worked. I also threw in a while loop to explain the out come of the experiment for shiggles. For 3 I also did a if statement to show the user the answer top each matrix question.

and this is question 4 with 3 at the top again. pretty much the exact same as the lecture example just with 2 position matrixes and a repeating force vector since the force never changes despite the position.

Class notes 8/27/15



first array and some simple math to work on it T.T

basic and intermediate math functions
basic and intermediate math functions
basic and intermediate math functions continuation




PV=nRT with some morlar weight division problem *yawn*



yeah not too positive what this is displaying besides me trying to figure out how to make a table from some random numbers i made.
creating a table for the first time, oh the feels
examples of common geometric equations and how to preform them in matlab

I believe this was an example of making matlab run an equation for the user, notice the names of the variables i chose. That being said it is actually nice to get an answer as neat as that to such an awful equation.
here we are learning how to create simple arrays using the different numbering functions that go by 1 a number you tell it to logrhythmically and by giving an equally spaced number of numbers between two numbers. confused? good