Question

Use matlab

a) Create a simulated data set b) Create a set of plots to determine the best transformation to linearize the data c) Fit a first order polynomial (y mx + b) to the linearized data to find the constants m and b d) Reconstruct the original equation from m and b in the linear fitted polynomial e) Plot the fitted equation. Radioactive decay is modeled by the equation: rt where A the amount of mass as a function of time (mg) A the original mass of decaying material (mg) the decay rate t the amount of time elapsed (years) Generate an set of mass measurements over time for Radium-226 (decay rate: 0.0436% per year). Use 0 st4000 years with r-0.000436 and A 20mg to generate 20 evenly spaced measurements of A. Next, add noise to your A vector to represent measurement error. Do this with the following code: This code generates a vector of length nSamples containing random values between-0.5 and +0.5, then scales each measurement by 10% . gnaiogl datg A is the A that you created above. The end result (Anoisy) has an artificial measurement error of up to 5% per measurement. Feel free to change the variable names. an ee o change the err ofup to 5% per Print the first and last values of A poisy to four decimal places. b) Determine which type of function provides the best fit by plotting the noisy data using the following transformations. Use the subplot command to include them in the same window. x-axis (your time data) In(x) In(x) y-axis lAngisyl Function Linear-y=mx + b Power -Y Exponential- Logarithmic -y m*Inx)+b In yl In y

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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)')

Command Window First noisy sample: 20.3115 mg at t= 0 years Last noisy sample: 3.3336 mg at t4000 years Choice of best function: Exponential m: -0.000443 b 3.007794 r: -0.000443 AO: 20.242687 Figure 1 Figure2 File Edit View Insert Tools Desktop Wiow Help File Edit View Insert Tools Desktop Window Help Mass vs time Mass vs Time Linear-Linear Axes Mass vs Time Best Polynomial Log-Log Axes 25 3.5 Data 20 20 Fitted Polynomial 2.5 18 10 16 4 10 Time (years) Mass vs Time Linear-Log Axes log(Time (years)) Mass vs Time 12 Log-Linear Axes 10 25 O 20 15 E 10 3.5 2.5 8 1.5 4 4 10 0 500 1000 1500 2000 2500 3000 3500 4000 Time (years) log(Time (years)) Time (years)

Add a comment
Know the answer?
Add Answer to:
Use matlab a) Create a simulated data set b) Create a set of plots to determine...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • HELP!! In Matlab The scenario is simple: A set of (x,y) data is available in the...

    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...

    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...

    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...

    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...

    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 c...

    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...

    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...

    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 a...

    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,...

  • please help with #1 a and b. thank you Use the following data for all problems:...

    please help with #1 a and b. thank you Use the following data for all problems: The data below defines the sea-level concentration of dissolved oxygen for fresh water as a function of temperature: T°C omg/L 0 8 16 14.621 11.843 9.870 24 32 40 8.418 7.305 6.413 a. Approximate o(19) using a 1st order Newton's interpolating polynomial. b. Approximate o(19) using a 2nd order Newton's interpolating polynomial. 2) Use linear algebra to find the coefficients of the 2nd order...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT