by using matlab
linreg() function file given below
`Hey,
Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
Please note you should have linreg function in your directory saved as linreg.m to run this program
clc
clear all
close all
format long
W=[70,75,77,80,82,84,87,90];
A=[2.1,2.12,2.15,2.2,2.22,2.23,2.26,2.3];
plot(W,A,'ob');
[a0,a1,r2]=linreg(W,log(A));
alpha=exp(a0);
beta=a1;
fprintf('alpha using linreg is %f\n',alpha);
fprintf('beta using linreg is %f\n',beta);
fprintf('r2 using linreg is %f\n',r2);
C=polyfit(W,log(A),1);
a0=C(2);
a1=C(1);
alpha=exp(a0);
beta=a1;
f=@(x) alpha*exp(beta*x);
SSR=sum((A-f(W)).^2);
SST=sum((A-mean(A)).^2);
r2=1-SSR/SST;
fprintf('alpha using polyfit is %f\n',alpha);
fprintf('beta using polyfit is %f\n',beta);
fprintf('r2 using polyfit is %f\n',r2);
x=0:100;
y=f(x);
hold on;
plot(x,y,'--r');
Kindly revert for any queries
Thanks.
by using matlab linreg() function file given below On average, the surface area A of human...
I need this program in MATLAB with different or another code. INPUT: x = [0 1 8 12 27]; y = [1 2 3 4 5]; nx = length(x); ny = length(y); n = length(x); if nx ~= ny display('Error. La cantidad de datos en x no es igual que los datos en y') end Sx = sum(x); Sxx = sum(x.^2); Sy = sum(y); Sxy = sum(x.*y); a1 = (n*Sxy - Sx*Sy)/(n*Sxx-(Sx)^2); a0 = (Sxx*Sy - Sxy*Sx)/(n*Sxx - (Sx)^2); m...
P2) Write a MATLAB function myLinReg Username that is defined below. Use the in-built MATLAB function sum( ) to ease your programming (you are NOT allowed to use polyfit() and polyval()). Test the output of this function with the results obtained by hand for P1. Submit printout of program and a screenshot of the command window showing the results for P1. function [coeffvec, r2]-myLinReg_Username (xi,yi) %Function file: myLinReg-Username .m Purpose : 8 To obtain the parameters of a L.S. linear...
*matlab* Hi, for the plotting of question C, the correct answer is the first curve graph when i use yp=alpha*xp^beta. why cant i use polyval for this? The solubility of oxygen in water S, is a function of the water temperature T. The solubility of O2 as millimoles of O2 per litre of water has been measured for several temperatures as shown in the table below. It is believed that the data follows the power relationship. i.e. S-: αΤβ where...
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...
please solve using matlab 4. Nonlinear Regression Fit the below data with the following curve-fit equation y bi (ebr + 2 1.0000 1.5431 3.7622 10.0677 27.3082 Define a function of the sum of squared residuals (fSSR) as a function of the regression coefficients, b's. Minimize the fSSR function and determine the regression coefficients. Guess what would be the built-in math function to generate the original data? Plot the function in the existing figure with a smooth dashed line, calculate the...
peruvian.txtProblem 1 (explore the data):In this exercise use the Peruvian blood pressure data set, provided in the file peruvian.txt (A NOTE for repeat students: The data is different from the data I shared last year.). This dataset consists of variables possibly relating to blood pressures of n = 30 Peruvians who have moved from rural high altitude areas to urban lower altitude areas. The variables in this dataset are: Age, Weight, Height, Pulse, Systol and Diastol. Before reading the data into MATLAB, it can be viewed in a...
Problem 5 (programming): Create a MATLAB function named lagrange interp.m to perform interpolation using Lagrange polynomials. Download the template for function lagrange interp.m. The tem Plate is in homework 4 folder utl TritonED·TIue function lakes in the data al nodex.xi and yi, as well as the target x value. The function returns the interpolated value y. Here, xi and yi are vectors while x and y are scalars. You are not required to follow the template; you can create the...
Consider the following data table: 0 2i = 0.2 0.4 f(xi) = 2 2.018 2.104 2.306 0.6 0.2 and 23=0.4 is The linear Lagrange interpolator L1,1 (2) used to linearly interpolate between data points 12 (Chop after 2 decimal places) None of the above. -2.50x+0.20 -5.00x+2.00 -5.00x+2.00 5.00x-1.00 Consider the following data table: 2 Ti = 0 0.2 0.4 0.6 f(x) = 2.018 2.104 2.306 0.2 and 23 = 0.4, the value obtained at 2=0.3 is Using Lagrange linear interpolation...
Matlab code: Task 5 As an engineer you are asked to calculate the approximate surface area of a lake in your local community. In order to do that, you decide to use a GPS to measure the x and y coordinates at various points around the lake. You pick a starting point and calibrate your GPS position at that point to be (0,0). You begin to walk around the lake collecting the following data below and eventually return to your...
solve all questions simply by using matlab. write all step here please 1Normal 1 No Spac Heading1 Heading 2 DISCUSSION Solve all tasks given below: 1. Consider function f(x) 3.5-0.5x cos(6x) for the value of x between -2.0 until 4.0. Draw the plot in dash line and in red colour, Label the title and all axes. 2. Consider the following functions for 0sxS pi: x() 10e0.St sin(3t +2) y(t) 7e-04t cos(5t - 3) (a) Draw both graphs on the same...