[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Vectorize for loop with sum
From: |
Rick T |
Subject: |
Vectorize for loop with sum |
Date: |
Thu, 9 Jun 2011 07:38:09 -1000 |
How can I vectorize this for loop?
t_rebuilt=linspace(0,1,length(inner_freq));
for ii=1:1:length(inner_freq);ii=ii+1;
aa_sig_rebuilt=inner_freq(ii,2)*cos(2*pi*t_rebuilt*inner_freq(ii,1)+inner_freq(ii,3));
aa_sig_combined=aa_sig_combined+aa_sig_rebuilt;
end;
I tried replacing it with the lines below to see if it worked but I just get a straight line when I plot it
aa_sig_rebuilt=inner_freq(ii,2).*cos(2*pi*t_rebuilt*inner_freq(ii,1)+inner_freq(ii,3));
and I also tried
aa_sig_rebuilt = sum(inner_freq(:,2).*cos(2*pi*t_rebuilt*inner_freq(:,1)+inner_freq(:,3)));
tia
--
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Vectorize for loop with sum,
Rick T <=