## How to create an orthogonal matrix in Matlab with one fixed column

matlab check if matrix is orthogonal
gram-schmidt matlab
orthogonal matrix calculator
check if vectors are orthogonal matlab
range of a matrix - matlab
matlab generate orthogonal vectors
matlab generate unitary matrix
basis vectors matlab

I want to create a square NxN matrix orthogonal, with the constraint that the first column is a column vector of k*ones(N,1), where k is a constant at choice. Is there any procedure?

I.e.

```A= [k * *;k * *;k * *]
```

is a 3x3 matrix, where the first column is a vector k*ones(3,1), and the other two vectors have to be created in such a way the matrix is orthogonal

Maybe this should be posted on Math.StackEchange where equations can be typed properly if you want a proper theoretical explanation. But if just want the code...

First, if `N` is the dimension of your matrix, this constrains the value of `k` to:

```k=sqrt(1/N);
A(1,:) = k*ones(1,N);
```

Then, the second row can be constructed with:

```A(2,:) = sqrt(0.5)*[1,-1,zeros(1,N-2)];
```

This creates a simple vector orthogonal to the first.

The third line can be computed with:

```aux = [1,1,-2,zeros(1,N-3)];
A(3,:) = aux/norm(aux);
```

The fourth:

```aux = [1,1,1,-3,zeros(1,N-4)];
A(4,:) = aux/norm(aux);
```

And so on.

In short:

```A=zeros(N);
k=sqrt(1/N);
A(1,:) = k*ones(1,N);
for i=2:N
aux = [ones(1,i-1),-(i-1),zeros(1,N-i)];
A(i,:) = aux/norm(aux);
end
```

orthogonal matrix with different size of rows and columns, I want to create a square NxN matrix orthogonal, with the constraint that the first column is a column vector of k*ones(N,1), where k is a constant at choice. Expanding a Matrix. You can add one or more elements to a matrix by placing them outside of the existing row and column index boundaries. MATLAB automatically pads the matrix with zeros to keep it rectangular. For example, create a 2-by-3 matrix and add an additional row and column to it by inserting an element in the (3,4) position.

Alternatively:

```kk = k*ones(3,1); % fixed first column (could be anything)
X = [kk, null(kk')']
```

gives you a square matrix with mutually orthogonal columns, no matter what's the vector `kk`. It will be an orthonormal matrix only when `norm(k)==1` (which implies `k=1/sqrt(3)` in your examples, as the others have noted). Note that the first case does not imply its rows are orthogonal, whereas the second one does.

How to create an orthogonal basis for the column space of a matrix , how to generate orthogonal matrix with different size of rows and columns? If your goal is to find a set of n vectors of length d, such that they are orthogonal to each The answer is as simple as virtually one line of code. In logical indexing, you use a single, logical array for the matrix subscript. MATLAB extracts the matrix elements corresponding to the nonzero values of the logical array. The output is always in the form of a column vector. For example, A(A > 12) extracts all the elements of A that are greater than 12.

I'm sorry I can't quote MATLAB code, but I'm sure this will be straightforward to code.

What you want is a Householder reflector These are othonormal matrices that are symmetric (and so are their own inverses). Given a vector v you can find a reflector H so that

```H*v = a*e1
```

where a is += length of v and e1 is (1,0,..)'

I'd imagine MATLAB has a routine for this.

Given the properties of H this means that the first column of H is parallel to v, and the other columns are orthogonal to v and to each other.

So if you scale the first column of H (it is of length 1) appropriately, you have your desired matrix.

Orthonormal basis for range of matrix - MATLAB orth, MATLAB Answers. Toggle Sub From there we have to use Gram-Schmidt to make the orthogonal basis. Here is my It works up until the nested forloops specifically the one on the inside. Following as a How do I fix this? Here is an  my assignment is to write afunction (input A) and returns an othogonal basis for Col(A). Professor wants me to use rref, and the jb row vector that comes with it to build a basis for Col(A).

Create orthonormal basis from a given vector, Q = orth( A ) returns an orthonormal basis for the range of A . The columns of Q are vectors, which span the range of Calculate and verify the orthonormal basis vectors for the range of a full rank matrix. Since A is rank deficient, Q contains one fewer column than A . Generate C and C++ code using MATLAB® Coder​™. So I need to create a matrix were first column of the matrix is 30 rows of the first column vector then second column of the matrix is also 30 rows of second column vector and same for the third column of the matrix which is also 30 rows of the third vector. Is there a very simple command for that beacuse i simply can't find.

how can I generate all possible mutually orthogonal permutative , I need to create an orthonormal basis from a given input vector. For example yz​=null(x).'; xyz=[x;yz]; %The rows of this matrix are the axes One such vector is. This MATLAB function returns the scalar 1. If the size of any dimension is 0, then X is an empty array.. If the size of any dimension is negative, then it is treated as 0.. If any trailing dimensions greater than 2 have a size of 1, then the output, X, does not include those dimensions.

How do I create orthogonal basis based on two "almost", As in case of order 3 I need two orthogonal matrices with fixed hamming distance 3 No number from {1,2,3} is repeated in row , column repetition is allow. I have a 469x1 matrix (interNode) and I want to make a second column with all rows having the same value (2) to give me a 469x2 matrix. Any help would be appreciated :) 0 Comments