I want to only fft last half of data from simulink
3 次查看(过去 30 天)
显示 更早的评论
I want to only apply fft to the last half of signal obtained from simulations in simulink. My take:
time=Vs_a.time(end/2:end);
vs_a=Vs_a.signals.values(end/2:end);
Ns=length(time);
Vsaf = abs(fft(vs_a))/Ns;
Vsaf(2:end)= Vsaf(2:end)*2;
This didn't give the results I expected, anyone got a clue what I'm doing wrong?
1 个评论
Adam
2016-8-31
You need to give more information that just that results are not as expected. What do you expect and what are you getting?
回答(2 个)
David Barry
2016-8-30
The (end/2:end) indexing syntax will fail if you have an odd number of elements in your array. You would need to handle this case and decide which element you want. You could use round or floor, for example:
time=Vs_a.time(round(end/2):end);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Transforms 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!