0
$\begingroup$

Why if we want to build the square matrix $A$ having in the j-th column the ordinates $y_i^j$ in the y5 vector, we have to elevate every column as it follow:

y5 = [-0.0822 -0.2888 -1.3464 -0.8785 1.0000];
A = [y5' (y5').^2 (y5').^3 (y5').^4 (y5').^5];
$\endgroup$

1 Answer 1

1
$\begingroup$

This is done because it is the simplest method to visually see what is happening. The following code is much less efficient, but will achieve the same result.

y5 = [-0.0822 -0.2888 -1.3464 -0.8785 1.0000];
[idxMat,y5mat] = meshgrid(1:5,y5); % build temporary matrices

A = y5mat.^idxMat; % perform exponentiation

In the temporary matrices, idxMat has the vector [1,2,3,4,5] repeated in every row and y5mat has the y5 vector repeated in every column.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .