Help concatinating in for loop
古いコメントを表示
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
回答 (1 件)
1 件のコメント
darova
2019 年 9 月 13 日
Maybe you forgot about X also?
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!