clear
clc
%%
%a
t=linspace(0,4000,20);
r=-0.000436;
A0=20;
A=A0*exp(r*t);
Noise=(rand([1 20])-.5).*A*.1;
A_Noisy=A+Noise;
fprintf('First noisy sample: %.4f mg at t= %d
years\n',A_Noisy(1),t(1))
fprintf('Last noisy sample: %.4f mg at t= %d
years\n',A_Noisy(end),t(end))
%%
%b
subplot(2,2,1)
plot((t),(A_Noisy),'b.','markersize',15)
xlabel('Time (years)')
ylabel('Mass (mg)')
title({'Mass vs Time';'Linear-Linear Axes'})
ylim([0,25])
subplot(2,2,2)
plot(log(t),log(A_Noisy),'b.','markersize',15)
xlabel('log(Time (years))')
ylabel('log(Mass (mg))')
title({'Mass vs Time';'Log-Log Axes'})
ylim([1,3.5])
subplot(2,2,3)
plot((t),log(A_Noisy),'b.','markersize',15)
xlabel('Time (years)')
ylabel('log(Mass (mg))')
ylim([1,3.5])
title({'Mass vs Time';'Linear-Log Axes'})
subplot(2,2,4)
plot(log(t),(A_Noisy),'b.','markersize',15)
xlabel('log(Time (years))')
ylabel('Log(Mass (mg))')
ylim([0,25])
title({'Mass vs Time';'Log-Linear Axes'})
%from the subplots, we see that the exponential function is the
best fit, as it is the closest to a straight line
fprintf('Choice of best function: Exponential\n')
%%
%c
P=polyfit(t,log(A_Noisy),1);
m=P(1);
b=P(2);
fprintf('m: %.6f b: %.6f\n',m,b)
%%
%d
r_n=m;
A0_n=exp(b);
fprintf('r: %.6f A0: %.6f\n',r_n,A0_n)
%%
%e
t_new=0:1:4000;
figure
plot(t,A,'.','markersize',15)
hold on
plot(t_new,A0_n*exp(r_n*t_new))
legend('Data','Fitted Polynomial')
title({'Mass vs time';'Best Polynomial'})
xlabel('Time(years)')
ylabel('Mass(mg)')
Use matlab a) Create a simulated data set b) Create a set of plots to determine...
HELP!! In Matlab The scenario is simple: A set of (x,y) data is available in the form of a simple text file – the first column represents x-values and the second column represents y-values. The task at hand is to provide the best model (or curve fit) to this set of data. Your application should provide the means to fit the following curve types to the data: Linear (first order polynomial) of form (?? = ???? + ??) with non-zero...
use the linearize model to estimate k and C0 based on the following data using matlab Required information Linear regression provides a powerful technique for fitting a best line to data. The below figure shows the transformations can be used to express the data in a form that is compatible with linear regression. Apart from the given figure, there are other models that can be linearized using transformations. For example, the following model applies to third-order chemical reactions in batch...
A wind tunnel test conducted on an airfoil section yielded the following data between the lift coefficient (CL) and the angle of attack (?): 12 1.40 16 1.71 20 1.38 de CL 0.11 0.55 0.95 You are required to develop a suitable polynomial relationship between ? and CL and fit a curve to the data points by the least-squares method using (a) hand calculations and (b) Matlab programming Hint: A quadratic equation (parabola) y(x)-aa,x +a x' can be used in...
Can you make matlab solve it? 2. An investigator has reported the data tabulated below for an experiment to determine the growth rate of bacteria k (per day) as a function of ox ygen concentration c (mg/L). It is known that such data can be modeled by the following equation: Where es and kmax are parameters 0.5 1.1 0.8 2.5 1.5 5.3 2.5 7.6 8.9 a) Use a transformation to linearize this equation. b) Then write a function m file...
USING MATLAB. For given data, estimate the length when time is at 3.5 seconds and at 13 seconds by utilizing the maximum number of data given, and provide the equation for the best fit curve, and plot the curve against the data. (a) Linear regression method (b) Exponential Function (c) Power Function (d) Saturation Function (e) Polynomial regression (f) Lagrange polynomial (8) Newton's divided-difference polynomial Time (sec) Length (in) 10 17 18 25 28 30 30 10 15 36 38
1. Problem 1. Given a data set (X, Y), use the least squares techniques to find the best ftting curve y-/() within the exponential family v ab) where a,b ER. The data set is given by, where, χ-io, 0.2, 0.4, 0.6, 08, 09, 1, 12, 14, 1.6] y 2, 2.5, 3.1, 3.9, 4.8, 5.4, 6, 7.5, 9.3, 11.6] In particular: a) Going from the original data (x,Y) set to the transformed data set (X, Z) with z(Y)-In (Y), verify that...
2. Suppose Y ~ Exp(a), which has pdf f(y)-1 exp(-y/a). (a) Use the following R code to generate data from the model Yi ~ Exp(0.05/Xi), and provide the scatterplot of Y against X set.seed(123) n <- 500 <-rnorm (n, x 3, 1) Y <- rexp(n, X) (b) Fit the model Yi-Ao + Ax, + ε¡ using the lm function in R and provide a plot of the best fit line on the scatterplot of Y vs X, and the residual...
R STUDIO Create a simulated bivariate data set consisting of n 100 (xi, yi) pairs: Generate n random a-coordinates c from N(0, 1) Generate n random errors, e, from N(0, o), using o 4. Set yiBoB1x; + , Where Bo = 2, B1 = 3, and eN(0, 4). (That is, y is a linear function of , plus some random noise.) (Now we have simulated data. We'll pretend that we don't know the true y-intercept Bo 2, the true slope...
Using the data inspector. Record some values for the height of the projectile as a function of time. Using these data and any graphical analysis program you like, create a graph of projectile height as a function of time and generate a quadratic fit to your data. My data is as follows: (time, height): (0.1s,1.25m), (0.3s, 3.46m), (0.6s, 6.03m), (0.8s, 7.25m), (1.1s, 8.35m), (1.3s, 8.6m), (1.5s, 8.45m), (1.8s, 7.49m), (2.2s, 4.84m), (2.6s, 0.62m) Initial: angle- 60 degrees, speed, 15 m/s,...
(I) Let's start with very simple data table 1.0 2.0 3.0 4.0 5.0 6.0 -1 ± 1.8 4±2.0 9+ 1.0 14 + 0.8 19 s 0.8 24 + 1.2 2% 1.8 34 ± 2.0 7.0 8.0 9.0 1. Plot a graph of y vs. X on a piece of graph paper 2. Is it a straight line? Draw the best-fit line. 3. Compute the slope and y-intercept for this line. Write the equation for y in terms of x using...