Thursday, October 15, 2015

Day - 12 Arrays and different data types

 We started he day with array types in matlab. Then talked about the data types, such as classes for each type. We discussed floating point number, integers and double. Finally went over string and char and then move onto symbolic and logical data. We finished the with creating a structure array with planetary data and called the data in the m-file.
Here are some pictures of examples done in class.

Conclusion:
 We learned of different arrays and different data types. Each matrices type of data have classes. We worked with logical and symbolic functions.


%HMWK 12
%12 - 1
syms x a b c d X %loads variables
ex1 = x^2-1 %
EX1 = sym('x^2 - 1 ')
eq1 = sym(' x^2=1 ')
EQ1 = sym('x^2 = 1 ')
subs(ex1,x,4) %answwer is 15
subs(EX1,x,4) %answer is 15
subs(eq1,x,4) %answer is 16==1
%12 - 2
v = [0:10]
subs(ex1,x,v) %answwer is array
subs(EX1,x,v) %answer is array
subs(eq1,x,v) %answer is [==] exprssion
%12 - 3
ex4 = a*x^2 + b*x + c
EX4 = sym('a*x ^2 + b*x + c ')
eq4 = sym('a*x^2 + b*x + c=0 ')
EQ4 = sym('a*x ^2 + b*x + c = 0 ')
subs(ex4,{'a' 'b' 'c' 'x'},{3 4 5 1:0.5:5}) %answer in fractions
subs(EX4,{'a' 'b' 'c' 'x'},{3 4 5 1:0.5:5}) %answer same as above
subs(eq4,{'a' 'b' 'c' 'x'},{3 4 5 1:0.5:5}) %answer == returns
subs(EQ4,{'a' 'b' 'c' 'x'},{3 4 5 1:0.5:5}) %answer same as above
%12 - 4
%They are symbolic
%12 - 5
syms m g l L f %loads variables
X = sym('f*2*pi = sqrt(m*g*L/l)') %epressed version
solve(X,'L') %solving X for L
%12 - 6
syms mtops mbottoms x %loads variable
water = sym(' 50 = 0.2*mtops + 0.65*mbottoms')    %water
ethanol = sym('-100*x + 0.35*mtops + 0.25*mbottoms')    %ethanol
methanol = sym(' 50 = 100*x + 0.45*mtops + 0.1*mbottoms')     %methanol
[mtops mbottoms x] = solve(water,ethanol,methanol) %answer
k = double([mtops mbottoms x]) %converts symbloic answers into double bytes for fprint
k1 = sprintf(' mass top %3.2f \n mass bottom %3.2f \n percent methanol %3.2f \n',k) %outprint
msgbox(k1) %display box

No comments:

Post a Comment