How to save answers from a Loop in one Matrix Column Wisw

1 view (last 30 days)
Hi Guys,
I am attaching the code below if someone can help me, I am running a file in loop,
The output of the loop will be as follows:
Output 1:
2
4
5
4
5
Output 2:
1
2
3
4
5
I want to save both the outputs in a single matrix as: Output 1 Output 2
It want my matrix to be as:
2 1
4 2
5 3
4 4
5 5
for S = 0.25:0.25:100;
T = 1650*S;
C1 = mean(LeadingTip(1:T));
C2 = mean(TrailingTip(1:T));
LT = LeadingTip(1:T);
TT = TrailingTip(1:T);
T1 = (1/Fs:1/Fs:S);
maxlag1 = 100;
cor_seq25 = xcorr([LT-C1],[TT-C2],maxlag1,'coeff'); %I want to save Cor_seq running in loop, as a matrix column wise
end

Answers (1)

VBBV
VBBV on 18 Apr 2021
S = 0.25:0.25:100;
for i = 1:length(S)
T = 1650*S(i);
C1 = mean(LeadingTip(1:T));
C2 = mean(TrailingTip(1:T));
LT = LeadingTip(1:T);
TT = TrailingTip(1:T);
T1 = (1/Fs:1/Fs:S);
maxlag1 = 100;
cor_seq25(:,i) = xcorr([LT-C1],[TT-C2],maxlag1,'coeff'); %I want to save Cor_seq running in loop, as a matrix column wise
end
Try this

Categories

Find more on Loops and Conditional Statements 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!