Question

Given x = [0,0.05, 0.01, 0.15, 0.2, 0.25, … , 0.95, 1] and f(x) = [1,...

Given x = [0,0.05, 0.01, 0.15, 0.2, 0.25, … , 0.95, 1] and f(x) = [1, 1.0043, 1.0172, 1.0387, 1.0687, 1.1074, 1.1546, 1.2105, 1.2749, 1.3479, 1.4296, 1.5198, 1.6186, 1.7260, 1.8420, 1.9665, 2.0997, 2.2415, 2.3918, 2.5507, 2.7183], write a MATLAB script that approximates the coefficients of f(x).

Homework Answers

Answer #1

MATLAB Code:

close all
clear
clc

x = 0:0.05:1;
f = [1, 1.0043, 1.0172, 1.0387, 1.0687, 1.1074, 1.1546, 1.2105, 1.2749, 1.3479, 1.4296, 1.5198, 1.6186, 1.7260, 1.8420, 1.9665, 2.0997, 2.2415, 2.3918, 2.5507, 2.7183];
p = polyfit(x,f,5); % Degree 5 polynomial fit
fprintf('Polynomial Fit of f(x):\n\tp(x) = (%.4f)*x^5 + (%.4f)*x^4 + (%.4f)*x^3 + (%.4f)*x^2 + (%.4f)*x + (%.4f)\n', p)

% Plotting
plot(x,f,'o',x,polyval(p,x))
xlabel('x'), ylabel('f(x)'), title('Degree 5 Polynomial Fit')
legend('Data Points', 'Polynomial Fit', 'Location', 'northwest')

Output:

Polynomial Fit of f(x):
   p(x) = (0.0089)*x^5 + (-0.0224)*x^4 + (0.0194)*x^3 + (1.7116)*x^2 + (0.0007)*x + (1.0000)

Plot:

Know the answer?
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
Similar Questions
Consider a single locus in a population with 4 alleles with frequencies 0.4, 0.25, 0.15, 0.2....
Consider a single locus in a population with 4 alleles with frequencies 0.4, 0.25, 0.15, 0.2. The genotypes are in Hardy-Weinberg equilibrium. What is the current heterozygosity in the population? If the population size is 100, what will the heterozygosity be after 10 generations? If the generation time is 20 years, how long will it take for the heterozygosity to be reduced by half?
Suppose we have 3 assets: Expected returns = [0.1 0.15 0.12] Standard déviations = [0.2 0.25...
Suppose we have 3 assets: Expected returns = [0.1 0.15 0.12] Standard déviations = [0.2 0.25 0.18] Correlations = [1 0.8 0.4 0.8 1 0.3 0.4 0.3 1] Find all possible pairwise two-asset portfolios and plot on a backround of random portfolios of all three assets. Comment on the efficient frontier.
In Matlab: Given the script: x = 1; x = fun(x-1); y = x-1 and the...
In Matlab: Given the script: x = 1; x = fun(x-1); y = x-1 and the function: function y = fun(x) x = x-1; y = x-1; end What is the output a) -2 b) -4 c) -3 d) -1
x P(x) 0 0.25 1 0.05 2 0.15 3 0.55 Find the standard deviation of this...
x P(x) 0 0.25 1 0.05 2 0.15 3 0.55 Find the standard deviation of this probability distribution. Give your answer to at least 2 decimal places    
Consider a CDF given below: F(x) = 0 for X< -3 = 0.2 -3<=X<-1 = 0.4...
Consider a CDF given below: F(x) = 0 for X< -3 = 0.2 -3<=X<-1 = 0.4 for -1<=X<2 = 0.6 for 2 <= X < 4 = 0.8 for 4 <=X<6 =1 for X>6 Find the PMF of X. Find the expected value of X. Find the second moment of X and the second central moment up to 2 decimal places
2. Consider the given seven symbols with probabilities as {A, B, C, D, E, F, G}...
2. Consider the given seven symbols with probabilities as {A, B, C, D, E, F, G} = {0.25, 0.20, 0.18, 0.15, 0.12, 0.06, 0.04}. Use Huffman coding to determine coding bits, entropy and average bits per symbol. Verify the same with Matlab . Verify the same with Matlab .Verify the same with Matlab ( very importent ) .
The pdf of two-component spliced distribution is given below. f(x) =0.01, for 0 ≤ x <...
The pdf of two-component spliced distribution is given below. f(x) =0.01, for 0 ≤ x < 50 and 0.02 for 50 ≤ x ≤ 75 and 0 otherwise. Find the variance of X.
Given a random variable X has the following pmf: X -1 0 1 P[X] 0.25 0.5...
Given a random variable X has the following pmf: X -1 0 1 P[X] 0.25 0.5 0.25 Define Y = X2 & W= Y+2. Which one of the following statements is not true? A) V[Y] = 0.25. B) E[XY] = 0. C) E[X3] = 0. D) E[X+2] = 2. E) E[Y+2] = 2.5. F) E[W+2] = 4.5. G) V[X+2] = 0.5. H) V[W+2] = 0.25. I) P[W=1] = 0.5 J) X and W are not independent.
Given a random variable X has the following pmf: X -1 0 1 P[X] 0.25 0.5...
Given a random variable X has the following pmf: X -1 0 1 P[X] 0.25 0.5 0.25 Define Y = X2 & W= Y+2. Which one of the following statements is not true? A) V[Y] = 0.25. B) E[XY] = 0. C) E[X3] = 0. D) E[X+2] = 2. E) E[Y+2] = 2.5. F) E[W+2] = 4.5. G) V[X+2] = 0.5. H) V[W+2] = 0.25. I) P[W=1] = 0.5 J) X and W are not independent.
Given the following table, answer the questions below. x f(x) 0 0.05 1 0.2 2 0.3...
Given the following table, answer the questions below. x f(x) 0 0.05 1 0.2 2 0.3 3 0.45 a) Find the mean of this probability distribution. Round your answer to one decimal place. b) Find the standard deviation of this probability distribution. Give your answer to at least 2 decimal places.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT