X=(x0,x1,....,Xn0-1) ==> Xhat=(x0,x0,x0,x0, x1,x1,x1,x1, ........ ,Xn0-1,Xn0​-1,Xn0-1,X​n0-1), How can I copy like this in vector?

X=(x0,x1,....,Xn0-1) ==> Xhat=(x0,x0,x0,x0, x1,x1,x1,x1, ........ ,Xn0-1,Xn0-1,Xn0-1,Xn0-1)
How can I copy like in vector?
x0 was copied number of 4(or any number)

 Accepted Answer

xhat = kron(X, ones(1,4))

2 Comments

Thank for your help.
Please, help me.
X= 1 2 3 4
Xhat = kron(X,ones(1,4))
Xhat = 1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
size(xhat) = 4x4
but
I want to chane Xhat like this
[1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4]
size(xhat) = 1x16
MATLAB does not have a syntax
X= 1 2 3 4
so that was not the way you created the vector.
The output you got tells me that your X is not a row vector like you asked in your question: your X is a column vector.
In the general case where you do not know whether you have a row vector or a column vector but you know for sure you want to end up with a row vector, then use
Xhat = kron(X(:).', ones(1,4))
or
Xhat = kron(reshape(X,1,[]), ones(1,4))
X(:).' and reshape(X,1,[]) do the same thing in different ways.

Sign in to comment.

More Answers (0)

Categories

Find more on Signal Processing Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!