plaese solve these problems

2 Comments

Rather than attaching an image of the homework problem, perhaps describe what you have tried so far and/or what is preventing you from completing the problem.
ı have no idea plaese help me

Sign in to comment.

 Accepted Answer

Star Strider
Star Strider on 17 Oct 2014
The question essentially wrote out for you what you need to do.
Hints: the randn and polyfit functions are your friends here!

2 Comments

can you give some codes using these functions for example first question
You have to repeat this 1000 times, so use a for loop for that.
In your loop, the first thing you need to do is to create a vector of x-values of length 50. It wants you to do this by adding 5 to a normally-distributed random variable with a mean of 0 and standard deviation of 1. These are the default values for randn, so you need to create a (1x50) vector of random numbers. You can do that with randn(1,50). Add 5 to those to create x, then substitute x into the equation for y. Do this calculation and the subsequent regression in each repetition of your loop.
Remember to save the coefficients of the linear regression (use polyfit) for each repetition in a matrix so you can then use the histc function and bar functions to calculate the histogram counts and plot them.
You will need to read the documentation for the various functions (most of which I have provided links to here), as well as for loops and matrix indexing if you have not used them before.
I suggest you start by doing everything once without a loop so you know how it all works. Then add the loop to do it 1000 times, and learn about the histc and bar functions to complete it.
If you have problems getting your code to run, post what you have done, describe what it is doing that it should not, or what it is not doing that it should. Include the full text of any error messages, and copy and post the error messages and the line the error refers to.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 17 Oct 2014

Commented:

on 17 Oct 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!