Values of vectors in matrix (changes in time)
Show older comments
Hello guys, how may I do this..
I have 4 vectors (signals in time)
t =0:pi/20:4*pi;
x1 = cos(t);
x2 = cos(2*t);
x3 = cos(3*t);
x4 = cos(4*t);
And I want to put current value of signal to matrix:
x = [x1 x3]
[x2 x4]
But for t = 0 values of signals in t = 0; for t = t0 + t_step ... etc, Just changes values in matrix in time, I hope you understard :)
Any idea?
Accepted Answer
More Answers (2)
Andrei Bobrov
on 11 Mar 2019
Edited: Andrei Bobrov
on 11 Mar 2019
1 vote
t =0:pi/20:4*pi;
x =reshape(cos((1:4)'*t),2,2,[]);
KSSV
on 11 Mar 2019
t =0:pi/20:4*pi;
x1 = cos(t);
x2 = cos(2*t);
x3 = cos(3*t);
x4 = cos(4*t);
A = zeros(2,2,length(t)) ;
for i = 1:length(t)
A(:,:,i) = [x1(i) x3(i) ; x2(i) x4(i)] ;
end
It can eb achieved without loop also. Read about reshape.
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!