Question

solve part BNote: Do not use MATLAB (or other programming languages) build-in functions for regression. (a) Write a MATLAB (or other prog

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

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc%clears screen
clear all%clears history
close all%closes all files
format long
x=input('Enter x vector: ');
y=input('Enter y vector: ');
[a03,a13,R3_2,a01,a11,R1_2,a02,a12,R2_2]=regression(x,y)

function [a0,a1,R_2]=LinearRegression(x,y)
A=[x(:) ones(numel(x),1)];
b=y(:);
C=A\b;
a0=C(2)
a1=C(1)
SSR=sum((y-a0-a1*x).^2);
SST=sum((y-mean(y)).^2);
R_2=1-SSR/SST;
end


function [a03,a13,R3_2,a01,a11,R1_2,a02,a12,R2_2]=regression(x,y)
[c1,c2,R1_2]=LinearRegression(x.*log(x),log(y));
a01=exp(c1);
a11=(c2);
f1=@(x) a01*x.^(a11*x);
[c1,c2,R2_2]=LinearRegression(x,(x./y));
a02=1/c2;
a12=a02*c1;
f2=@(x) a02*x./(a12+x);
[a03,a13,R3_2]=LinearRegression(x,y);
f3=@(x) a03+a13*x;
xx=linspace(min(x),max(x));
plot(xx,f3(xx),xx,f1(xx),':',xx,f2(xx),'--',x,y,'o');
legend('Linear','Power','Saturation','data points');
end

- 5 x Pradeep Figure 1 - 0 X 56 Search Documentation Edit View Insert Tools APPS EDITOR Insert B fx - Go To - Comment % 9 Fin

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
solve part B Note: Do not use MATLAB (or other programming languages) build-in functions for regression....
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
  • matlab multiple regression

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

  • P2) Write a MATLAB function myLinReg Username that is defined below. Use the in-built MATLAB func...

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

  • Please Use C++ for coding . . Note: The order that these functions are listed, do...

    Please Use C++ for coding . . Note: The order that these functions are listed, do not reflect the order that they should be called. Your program must be fully functional. Submit all.cpp, input and output files for grading. Write a complete program that uses the functions listed below. Except for the printodd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention...

  • all the codes should be done in matlab Part C (Based off week 12 workshop content) Since the implementation of the C...

    all the codes should be done in matlab Part C (Based off week 12 workshop content) Since the implementation of the CityCycle scheme in October 2010, the Bris- bane council has recorded the umber of City Cyele trips every month. The results are available in the CityCycleData.es file on Blackboard 1. Import the data into MATLAB using the csvread funetion, and then visualise the data with the scatter fnction Comment on whether a linear model would be appropriate to use....

  • Please write down the equation for calculating the probability & use c language for programming part....

    Please write down the equation for calculating the probability & use c language for programming part. Thank you! Prob. 5 (20pts) (Birthday attack) A birthday attack is a type of cryptographic attack that exploits the mathematics behind the birthday problem in probability theory. It can be used to find collisions in a cryptographic hash function. Suppose that we have a hash function which, when supplied with a random input, returns one of 256 equally likely values. The attack generates n...

  • by using matlab linreg() function file given below On average, the surface area A of human...

    by using matlab linreg() function file given below On average, the surface area A of human beings is related to weight W and height H. Measurements of several individuals of height 180cm are provided below. It is believed that the following data can be modelled using an exponential equation A = aeBW W (kg) 70 2.1 75 2.12 77 2.15 80 2.20 82 2.22 84 2.23 87 2.26 90 2.30 A (m2) A. Show by hand with pen and paper...

  • Please solve part d in MATLAB Problem Statement Consider the Shockley diode equation, which approximates the...

    Please solve part d in MATLAB Problem Statement Consider the Shockley diode equation, which approximates the current-voltage (characteristic) curve of a diode: Here, is the current flowing through the diode (in amperes), and Vo is the voltage drop across the diode (in volts). VT is the thermal voltage, which varies based on the temperature. Assume that VT0.026 V, which is true when the diode is a little above room temperature. Therefore, in this equation, there are two unknown parameters that...

  • MATLAB Part 1 – randFloatValue.m This function accepts two numbers, lower and upper, and returns a...

    MATLAB Part 1 – randFloatValue.m This function accepts two numbers, lower and upper, and returns a random number in between. The rand() function will be useful here. Part 2 – getValue.m getValue has three parameters: - prompt: A string that is displayed to the user. This should be passed to your input function. - lower: The lowest number that the user is allowed to input - upper: The highest number that the user is allowed to input This function should...

  • I need help with parts A B D E and F. Please show hand work for...

    I need help with parts A B D E and F. Please show hand work for solving A and B while D and E should be matlab codes. How do i pick the right graph for part F? 5 2 4 6 Linear spline: s fi+ (x-x) 2) Given the points 40 78 125 256 348 425 X1-x a) Write the correct linear spline equation to interpolate for x 4.72, simplifying where appropriate to get to the slope-intercept form. (4...

  • please answer the second part first part answered. the answer to the first part is at...

    please answer the second part first part answered. the answer to the first part is at the bottom bring the rest of the place HAVE TO BE SOLVED WİTH C PROGRAMMİNG A programming task is given in below (i.e., you are supposed to write a single program involving all 5 tasks in below). You should write a C program and upload your c/cpp file . Students are allowed to use MAK104E course (powerpoint) slights. 1) Three geometric entities (a circle,...

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