plaese solve these problems

2 Commenti

Geoff Hayes
Geoff Hayes il 17 Ott 2014
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.
ertunc
ertunc il 17 Ott 2014
ı have no idea plaese help me

Accedi per commentare.

 Risposta accettata

Star Strider
Star Strider il 17 Ott 2014

0 voti

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

2 Commenti

ertunc
ertunc il 17 Ott 2014
can you give some codes using these functions for example first question
Star Strider
Star Strider il 17 Ott 2014
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by