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

3 vues (au cours des 30 derniers jours)
Nihar Jariwala
Nihar Jariwala le 18 Avr 2021
Réponse apportée : VBBV le 18 Avr 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

Réponses (1)

VBBV
VBBV le 18 Avr 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

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by