Question
please solve this in matlab platform, will solving write this mydata=importdata(‘’cars.txt’’,”|”,1) like this i hv the cars.txt data in my pc.
Analyze the data in cars.txt which you have to download from the section of Sinif Dosyalari on Ninova. [35 points] Write one
0 0
Add a comment Improve this question Transcribed image text
Answer #1

myData=importdata("cars.txt","|",1) ;
curb = myData.data(:,1); % dependent variable
lngth = myData.data(:,2); % independent variable; name 'lngth' is to avoid
                            % confusion with in-built MATLAB function length

% a. observe whether or not dependent variable curb has linear relation with independent variable lngth

figure;plot(lngth,curb)

% b. fit regression line using least square method

mean_l = mean(lngth);
mean_c = mean(curb);

for i=1:length(lngth)
    std_l(i) = (lngth(i) - mean_l)^2;
    cov_lc(i) = (lngth(i) - mean_l)*(curb(i) - mean_c);
end

m = sum(cov_lc)/sum(std_l); % slope of regression line
b = mean_c -m*mean_l; % intercept of regression line
curb_fit = m*lngth + b; % equation of regression line

% c. plot the regression line

figure;plot(lngth, curb_fit)

% d. forecast values of curb for length = [100 150 200]

curb_100 = m*100 + b;
curb_150 = m*150 + b;
curb_200 = m*200 + b;

Add a comment
Know the answer?
Add Answer to:
please solve this in matlab platform, will solving write this mydata=importdata(‘’cars.txt’’,”|”,1) like this i hv the...
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
  • Please I need help with MATLAB .. PLease help me . Thankyou Write Matlab code to...

    Please I need help with MATLAB .. PLease help me . Thankyou Write Matlab code to plot a 2D sinc function over a 2D cartesian grid where x ranges from 100 to 355 and y ranges from 0 to 255 and the sinc is centered at somewhere not midway in the grid. First plot the grid, and then plot the function on the grid (both as grayscale and as a surface plot). Comment the code well, generate the figures and...

  • The β 1 term indicates a. the Y value for a given value of X. b....

    The β 1 term indicates a. the Y value for a given value of X. b. the average change in Y for a unit change in X. c. the Y value when X equals zero. d. the change in observed X for a given change in Y. What does regression analysis attempt to establish? a. linearity in the relationship between independent variables b. a mathematical relationship between a dependent variable, for which future values will be forecast, and one or...

  • I need help solving these questions,please don’t know how to solve it by using matlab.!

    i need help solving these questions,please don’t know how to solve it by using matlab.! Solve the following questions Ol: You are required to develop a script to calculate the volume of a pyramid, which is 1/3 *base *height, where the base is length *width. Prompt the user to enter values for the length, width, and height, and then calculate the volume of the pyramid. When the user enters each value, he or she will then also be prompted to...

  • Please use Excel Solver. Consider the following set of time series sales data for a growing...

    Please use Excel Solver. Consider the following set of time series sales data for a growing company over the past 8 months: Month Sales 1 15 2 13 18 4 22 20 6 23 7 22 8 21 1. Construct a time series plot. What type of pattern exists? 2. Develop a forecast for the next month using the averaging method. 3. Develop a forecast for the next month using the naïve last-value method. 4. Develop a forecast for the...

  • MATLAB Question: Write a script for the problem pictured. Please send the script, not just the...

    MATLAB Question: Write a script for the problem pictured. Please send the script, not just the printout. Make sure your script allows you to input a value for n so when prompted, in the command window, user types n value. The n value should be the f_k if k ==1 .... Please also send print outs if you can. BELOW IS A SAMPLE ANSWER THAT DID NOT PUT THE INPUT SCRIPT NEEDED FOR THIS QUESTION TO BE CORRECT. YOU CAN...

  • I need this program in MATLAB with different or another code. INPUT: x = [0 1...

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

  • For expert using R , I solve it but i need to figure out what I...

    For expert using R , I solve it but i need to figure out what I got is correct or wrong. Thank you # Simple Linear Regression and Polynomial Regression # HW 2 # # Read data from csv file data <- read.csv("C:\data\SweetPotatoFirmness.csv",header=TRUE, sep=",") head(data) str(data) # scatterplot of independent and dependent variables plot(data$pectin,data$firmness,xlab="Pectin, %",ylab="Firmness") par(mfrow = c(2, 2)) # Split the plotting panel into a 2 x 2 grid model <- lm(firmness ~ pectin , data=data) summary(model) anova(model) plot(model)...

  • Please step by step like how can I do them by hand Solve by hand (or...

    Please step by step like how can I do them by hand Solve by hand (or you can use Excel). Solving by hand is preferred since you will not have access to a computer duripg the exams or quizzes Sue Higgins, the sales manager at The Boler Corporation, has given you the following information regarding the sales history of one of Boler's products, the Candi Kane: 330 350 300 270 235 220 195 180 a. Plot the quarterly sales data...

  • please use matlab Goal: Solve for the loads of the chain saw under different loading conditions....

    please use matlab Goal: Solve for the loads of the chain saw under different loading conditions. The loads on a chain saw as it cuts a log can be represented with the following equations: Ar +B -R cos(60) 0 My-W +By - R sin(60)0 Ar is the reaction load in the x-direction at point A (lb) Ay is the reaction load in the y-direction at point A (Ib) W is the weight of the chain saw (lb) R is the...

  • answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for...

    answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for a user defined function that is named Feynman and has input variables q and e, and outputs L and M. (Comment out of this line). 2. Using zeros, ones, and eye commands write the one line syntax to create the following matrix: 00000 01100 01010 01001 3. Write the syntax for the user defined function that calculates the surface area and volume of a...

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