Generate a 15-by-2 matrix q with random numbers

someone please help me with these solutions
a)Generate a 15-by-2 matrix q with random numbers b) create a 15-by-1 vector of sequential natural numbers from 1to 15 and name it X c)Plot using X and the first column of the matrix q(as Y): d)on the same chat plot using X and the second column of matrix q (as y)
2. Calculate the mean fo reach row of q b) calculate the standard deviation for each column of q

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 10 月 3 日
編集済み: KALYAN ACHARJYA 2018 年 10 月 3 日

0 投票

a)
p=100*rand(15,2);
Please learn how to generate random arrays here see the documentation
--------------------------------------------------------------------------
b) Find X Try yourself, first do the creat 15 by 1 and modify it for 1 to 15 number, you can fix the min and max limit value.
-------------------------------------------------------------------
c) Plot read the 1 column of p by q(:,1) and 2nd colm q(:,2) and plot the required (as per question)
---------------------------------------------------------------------
Hope this help you,
Learning by doing is the best way, try it, if you will find any difficulty share here, we are here to help you.
Good Wishes..!

6 件のコメント

Joe anson
Joe anson 2018 年 10 月 3 日
please send correct answers so i can cross check if what i have is right
Steven Lord
Steven Lord 2018 年 10 月 3 日
Post what you've written. We can tell you if what you've written looks right. We may even be able to offer some suggestions for how to make your code easier to read and/or more efficient.
Joe anson
Joe anson 2018 年 10 月 3 日
>> q=int8(100*rand(15,2))
q =
15×2 int8 matrix
16 76
97 74
96 39
49 66
80 17
14 71
42 3
92 28
79 5
96 10
66 82
4 69
85 32
93 95
68 3
>> x=int8(15*rand(1,15))
x =
1×15 int8 row vector
7 6 11 12 3 7 7 10 11 11 4 10 10 2 2
std(q,0,2) Im trying to find std for each colomn of q but i keep getting error
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 10 月 3 日
Your question a) is done. (q generation) next ?? Which steps you are doing?
Joe anson
Joe anson 2018 年 10 月 3 日
I just need to calculate standard deviation for each column of q. but its not working this is what i did std(q,0,2)
Steven Lord
Steven Lord 2018 年 10 月 3 日
The std function does not accept values of an integer type as input. It's unlikely that the standard deviation of an integer vector would itself be an integer value and so able to be stored exactly in a vector of an integer type.
Nothing in the statement of the assignment indicated that your q matrix had to be an int8 array. I would omit the int8 call in your code, which will make q a double array. The std function can compute the standard deviation of a double array.
If you need to generate random integer values, consider the randi function or calling round on the numbers generated by 100*rand. If you don't need to generate random integer values, just use 100*rand on its own.
About your x vector, it doesn't seem like it satisfies the requirements of the assignment. What you posted doesn't look "sequential" to me. I believe one of the examples on this page may be of use to you.

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

カテゴリ

ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索

質問済み:

2018 年 10 月 3 日

コメント済み:

2018 年 10 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by