필터 지우기
필터 지우기

Saving data of plotted sine wave into excel file or display on matlab as data (not visual graphs)

조회 수: 9 (최근 30일)
Hi everyone,
I am trying to plot a 5 Hz sine wave with sampling frequency of 500 Hz for 5 seconds long;
The following is the code I wrote:
fs= 500;
T=1/fs;
D= 5;
t= 0:T: D-T;
f=5;
A= 0.001;
x= A* sin(2*pi*f*t)
figure('Name',' tACS Signal')
plot(t,x)
xlabel('Time (s)');
ylabel('Amplitude of Current (A)');
So, I wanted to get all data points that creates this sine wave, both axis (time) and (current) into matrices (2 columns with about 2500 rows). Then, I think the process to convert .mat to .csv is simple. Please assist! Thank you very much.
Regards,
Anis

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 3월 17일
Why a mat file first? Why not just write the data to a file using writematrix?
writematrix([t;x]','sinwave.csv')
  댓글 수: 2
Anis Fatini Abdul Aziz
Anis Fatini Abdul Aziz 2021년 3월 17일
Oh, we can do that? I thought it has to be done like the usual way. Hence my question. Thank you!
Cris LaPierre
Cris LaPierre 2021년 3월 17일
Yes, you can do it that way. It worked on my computer. There are many ways to write data to file. See the Data Import and Export page for more.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by