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

2 次查看(过去 30 天)
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

回答(1 个)

VBBV
VBBV 2021-4-18
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

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by