Help concatinating in for loop

3 visualizzazioni (ultimi 30 giorni)
Flyers28
Flyers28 il 13 Set 2019
Commentato: darova il 13 Set 2019
I can not seem to figure out something that should be so intuitve. I need to store the values of x end to end for each pass of the first for loop. So when r=2 it stores the values of x right after the values of x when r=1. This will create a large 1x44100 vector which I will then use to plot and generate a sound clip. Some code didn't get copied ie Ar and Ac are from the size command. The other varaibles are already defined from a loaded file so don't sweat that. The reason I am creating a vector instead of an areay is because the soundsc command only likes vectors.
x=0; %initializ x to 0
numWin = [1: (0.05*fs)]; %generates array for #samples/window 1:2205
for r = 1:Ar %Sets The row or Window to be calculated
t=numWin ./ fs; %converts sample/window to sec/window
for c = 1:Ac %Sets the column for each frequency to be calc
xt = 2 * abs(A(r,c)) * cos(2*pi* freqs(r,c)* t + angle(A(r,c)));
x = x + xt; % Sums together each xt to generate sum for all values of xt
end
numWin = numWin + length(numWin); %increments to next time window
tnew(r,:)=t; %stores time for each window into an array for each pass through loop
end

Risposte (1)

Flyers28
Flyers28 il 13 Set 2019
Modificato: Flyers28 il 13 Set 2019
I think I figured it out... albeit probably the worst way possible. But it worked. in the first floop I just did xnew(1,(r*blahblah - blah):(r*blahblah)) = x.
Still open to what the experts have to say though.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by