How to do this in Matlab?

1 次查看(过去 30 天)
Shing Sheung Mak
Shing Sheung Mak 2018-10-17
回答: Luna 2018-10-17
1.Create a 100 X 100 random matrix (use the command randn) called B.
2.From B, create a matrix K which is a random matrix from a normal distribution with mean 4 and variance 16.
3.Create two vectors, v and z, which are respectively the first and the last row of K.
4.Plot v and z in the same graph, using as horizontal axis a vector t which contains the first 100 natural numbers.
5. The line of v must be red, a solid line, and the marker must be a circle. The line for z must be green, a dashed line, and the marker must be a star.
6. Add a legend to the plot.
  1 个评论
Steven Lord
Steven Lord 2018-10-17
This sounds like a homework assignment. If it is, show us what you've tried to solve the problem and describe specifically where you're having difficulty and we may be able to offer some guidance.
If you're not sure even where to start, I recommend either contacting your professor or teaching assistant or going through the tutorials in the Tutorials section on the Support webpage. The MATLAB Onramp tutorial should cover most if not all of the topics you'd need to complete that assignment.

请先登录,再进行评论。

采纳的回答

Luna
Luna 2018-10-17
Hi Shing
I can only recommend you which functions you should look at with their links below:
1) First look at randn function in below link:
2) For this you can use normpdf function to create a random matrix according to your mean and standart dev.
3) Your K is a matrix so you can get first and last row using below:
v = K(1,:)
z = K(end,:)
4) For plotting check the plot function below:
To plot 2 lines in a figure use the below command:
hold on
link for hold:
To create your natural numbers t use this:
t = 1:1:100
5) & 6) you can look plot function in details for color&marker style.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by