2 件のコメント

Geoff Hayes
Geoff Hayes 2014 年 10 月 17 日
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 2014 年 10 月 17 日
ı have no idea plaese help me

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2014 年 10 月 17 日

0 投票

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

2 件のコメント

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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2014 年 10 月 17 日

コメント済み:

2014 年 10 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by