Home /
Expert Answers /
Computer Science /
nbsp-the-template-code-generates-a-row-vector-vec-that-is-a-random-1-times-4-vector-of-i-pa847
(Solved):
The template code generates a row vector vec that is a random \( 1 \times 4 \) vector of i ...
The template code generates a row vector vec that is a random \( 1 \times 4 \) vector of integers and then uses a for loop to build a \( 3 \times 4 \) matrix mat, where each row ture matrix is equal to the values of vec multiplied by the power of the row number. For example if \[ v e c=\left[\begin{array}{llll} 2 & 4 & 6 & 8 \end{array}\right] \] then the generated matrix will be: \[ \overline{m a t}=\left[\begin{array}{cccc} a^{1} & b^{1} & c^{1} & d^{1} \\ a^{2} & b^{2} & c^{2} & d^{2} \\ a^{3} & b^{3} & c^{3} & d^{3} \end{array}\right]=\left[\begin{array}{cccc} 2 & 4 & 6 & 8 \\ 4 & 16 & 36 & 64 \\ 8 & 64 & 216 & 512 \end{array}\right] \] However, the code below has bugs, and you need to fix them! Script 0 \( 1 \% \) generating the random vector 2 vec \( =\operatorname{randi}\left(\left[\begin{array}{ll}1 & 10\end{array}\right], 1,4\right) \); \( 3 \% \) fiv tha rade halnoil