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 件)

Flyers28
Flyers28 2019 年 9 月 13 日
編集済み: Flyers28 2019 年 9 月 13 日

0 投票

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.

1 件のコメント

darova
darova 2019 年 9 月 13 日
Maybe you forgot about X also?
1Capture.PNG

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2019 年 9 月 13 日

コメント済み:

2019 年 9 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by