フィルターのクリア

Trouble with for-loop and fft

4 ビュー (過去 30 日間)
shawn finley
shawn finley 2021 年 8 月 13 日
コメント済み: shawn finley 2021 年 8 月 16 日
So the error I get in my code i am not understanding see attached code and error

採用された回答

Dave B
Dave B 2021 年 8 月 13 日
On line 33 of 'U296' you have the line
xdft=fft(signal.x_0_003{k},n)/L;
inside the fft you see:
signal.x_0_003{k}
but signal.x_0_003 is not a cell (or other type that supports {}).
What is class(signal.x_0_003)? Did you mean to use () instead of {}?
  3 件のコメント
Dave B
Dave B 2021 年 8 月 16 日
signal is a table
signal.x_0_003 is a variable in that table, my guess is that it contains a vector of values. You cannot use {} to index into this. I don't see how k would provide a time window here, but it's a little hard to say without knowing more about the structure of your table.
Here are some examples with table indexing that might help:
x=(10:10:100)';
t=table(x)
t = 10×1 table
x ___ 10 20 30 40 50 60 70 80 90 100
k=3;
t.x(3)
ans = 30
t.x(k:k+5)
ans = 6×1
30 40 50 60 70 80
x2 = {1:5;5:10:30;1:3:12};
t=table(x2)
t = 3×1 table
x2 _____________ {[1 2 3 4 5]} {[ 5 15 25]} {[ 1 4 7 10]}
t.x2{2}
ans = 1×3
5 15 25
shawn finley
shawn finley 2021 年 8 月 16 日
thanks for the clairifacation on the indexing

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

その他の回答 (1 件)

dpb
dpb 2021 年 8 月 13 日
What's the purpose of the loop over k?
You have the time history apparently as variable x_0_003 in the table which one presumes will be the third column.
If you want the FFT() of it, just write
xdft=fft(signal.x_0_003,n)/L;
There doesn't seem any point in the for...end loop at all.
NOTA BENE:
There's also no need to create copies of the table data into local variables time and volts; use the table variables directly. You could fix up the names in the table to be more meaningful either on input or later --
signal.Properties.VariableNames(2:3)={'Time','Volts'};
and then use
plot(signal.Time,signal.Volts)
  2 件のコメント
shawn finley
shawn finley 2021 年 8 月 16 日
The purpose of the for-loop is to analise the frequency that the fft generates over time.
I will look at using teh signal.Properties.VariablesNames code, but if it uses the signal tool box I don't have that.
shawn finley
shawn finley 2021 年 8 月 16 日
Just to be clear I do not have the Signal Processing Toolbox, sorry and Thanks.

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

カテゴリ

Help Center および File ExchangeTransforms についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by