Exam 2: Review Flashcards
Determine the best fit cubic function through ordered pairs (y,z); display the constant term of the function
[p, s] = polyfit(y,z,3)
disp(p(4))
Create a Cartesian plot of ordered pairs (x,y) in the upper right quadrant of figure number 66.
figure(66)
subplot(2,2,2)
plot(x,y)
Place a message on the plot at coordinates (5,10) that displays the value of a numeric array, CLmax
text(5,10, num2str(CLmax))
loglog(g,d,’–gd’)
plot of d as a function of g, both axis logarithmically, scaled dashed green line with green diamond data markers
data = data(find(data~=0))
removes zeros from the data array
z = uiputfile(‘*.bmp’,’Save data’)
z is the user selected location to save .bmp image. A command window will appear and allows the user to select where they wish to save the .bmp file
set(gca,’YDir’, ‘Reverse’)
gca = get current axis
reverse direction of the y axis for the current set of axes
command that would plot data in teh straightest alignment and include a dotted red line with res squares.
semilogy(x,y,’:rs’)
List the three basic construsts of “structured programming” common to all programming languages
- sequential
- conditional
- iterative
When do you use a for loop?
Use a for loop when you know how many cycles the loop will need to complete, but not the final result.
When do you use a while loop?
when you know the final condition but not how many cycles it will take.
What is the difference between curvefit and spline?
Spine goes through every data point,
Curvefit does not
List four basic mathematical functions we used for modeling data
- exponential
- Logarithmic
- Linear
- Power
What is the forward difference?
(y_i+1 - y_i)/(x_i+1 - x_i)
What is the backward difference?
(y_i - y_i-1)/(x_i - x_i-1)
What is the central difference?
(y_i+1 - y_i-1)/(x_i+1 - x_i-1)
What does it mean for a numerical method to be O(h^2)?
absolute error is proportionate to h^2 so if we have h the error drops to (1/2)^2 = 1/4
What is the criterion that makes a generalized curvefit equation a “best fit” model for the data?
for a best curve fit model, the R^2 value needs to be closest to 1 as possibl;e
Explain the criteria for using a for loop and a while loop?
"for" = known number of iterations, unconditional "while" = conditional, unknown number of iterations, performs expression until the logical expression is false
Explain the effects numerical integration and differentiation have on the propagation of uncertainty in data.
integration - attenuates uncertainty (lowers)
differentiation - increases uncertainty (amplifies)
Determine the definite integral of a function where the array f contains values of the dependent variable and hte array t contains values of hte independent variable
p = trapz(t,f)
Determine the derivative dp of a polynomial where the array p contains the coefficients of the polynomial arranged in descending powers
dp = polyder(p)
Assume that a plot already exists in the current figure window and its aces are in polar coordinates To this plot, add another data series of the variables theta and r and plot it with red circles and a dashed line
hold on
polar(theta,r,’–or’)
Plot hte variable principal as a function of the variable time on a plot with linear scaling on the x axis and logarithmic scaling on the y axis. Locate this plot in the lower right hand quadrant of the figure window
subplot(2,2,4)
semilogy(time,principal)
Use teh cursor to paste a comment on the current figure that displays the value of hte variable earnings. Indicate in this comment that earnings is calculated at year’s end and that the units are in dollars.
comment=[‘year end earnings,’ num2str(earnings)]
gtext(comment)