plot a sinusoidal signal from a file.dat

22 ビュー (過去 30 日間)
Souhir FH
Souhir FH 2016 年 11 月 27 日
コメント済み: Star Strider 2016 年 11 月 28 日
Hi everyone, I have stored values of a sinusoidal signal in a file.dat, i worked with a Frequency of sampling which is worth 8000hz,now i want to plot my signal from the file.dat in matlab but i don't know how, can you help me please!?

採用された回答

Star Strider
Star Strider 2016 年 11 月 27 日
I would do it this way:
fidi = fopen('file.dat', 'rt'); % Open File For Reading Text
Dc = textscan(fidi, '%f', 'CollectOutput',true); % Change ‘textscan’ Arguments To Match Your File
D = cell2mat(D); % Create Numeric Array
Fs = 8E+3; % Sampling Frequency (cycles/time unit)
Ts = 1/Ts; % Sampling Interval (time unit/cycle)
t = linspace(0, 1, length(D))*Ts; % Time Vector (Delete If You Saved Your Time Vector In Your File)
figure(1)
plot(t, D) % Plot Your Data
grid
Note This is quite obviously UNTESTED CODE. A version of it should work. You will have to experiment with it with your data.
See the documentation for the various functions to understand how to use them, and how they work.
  2 件のコメント
Souhir FH
Souhir FH 2016 年 11 月 28 日
Thank you very much now i can plot the signal.
Star Strider
Star Strider 2016 年 11 月 28 日
My pleasure.

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

その他の回答 (1 件)

Tamir Suliman
Tamir Suliman 2016 年 11 月 27 日
this how it will work
first you will have to import the dat file to matlab using import command
then assign that to a variable
for example import file.dat
d=file
then use that data and sub in to yoru sin equation
y = sin(d()*t)
whatever your t value is
then plot the signals
  1 件のコメント
Souhir FH
Souhir FH 2016 年 11 月 27 日
I do this, there is not error but the signal isn't sinusoidal, it is continued.

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

カテゴリ

Help Center および File ExchangeSignal Generation, Manipulation, and Analysis についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by