data generation from given

조회 수: 1 (최근 30일)
AKHILESH KUMAR
AKHILESH KUMAR 2017년 1월 27일
답변: Sergey Kasyanov 2017년 1월 27일
given a function y(t)=10*sin(200t)+20*cos(200t^2). i want to generate, save, load and plot the data.
  댓글 수: 1
Sergey Kasyanov
Sergey Kasyanov 2017년 1월 27일
What format of saved data do you prefer?

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

답변 (1개)

Sergey Kasyanov
Sergey Kasyanov 2017년 1월 27일
Define t:
t=[0:1e-3:1e-1];
Define y:
y=10*sin(200*t)+20*cos(200*t.^2);
Save data:
%to txt
fID = fopen('text.txt','w+');
fprintf(fID,'%f\r\n',t,y);
fclose(fID)
Load data:
%from txt
A = importdata('text.txt');
t=A(1:length(A)/2);
y=A(length(A)/2+1:end);
Plot data:
plot(t,y);

카테고리

Help CenterFile Exchange에서 Prepare Model Inputs and Outputs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by