Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Nihar Jariwala
Nihar Jariwala am 18 Apr. 2021
Beantwortet: VBBV am 18 Apr. 2021
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

Antworten (1)

VBBV
VBBV am 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

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by