data generation from given

1 Ansicht (letzte 30 Tage)
AKHILESH KUMAR
AKHILESH KUMAR am 27 Jan. 2017
Beantwortet: Sergey Kasyanov am 27 Jan. 2017
given a function y(t)=10*sin(200t)+20*cos(200t^2). i want to generate, save, load and plot the data.
  1 Kommentar
Sergey Kasyanov
Sergey Kasyanov am 27 Jan. 2017
What format of saved data do you prefer?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sergey Kasyanov
Sergey Kasyanov am 27 Jan. 2017
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);

Kategorien

Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by