필터 지우기
필터 지우기

Extract a MATLAB plot in a text file of points

조회 수: 1 (최근 30일)
Sebsatien
Sebsatien 2012년 12월 13일
Hi
I would like to ask for your help about extracting a 2D plot in Matlab into a text file containing an array of the plots points (x and y). What should I do excactly?
Thanks for the reply
Here's the figure. It's a simple sinusoidal curve along 1000 points.
I just one to extract the y values and the x values in a text file containing 2 arrays of points (x and y)
Thanks very much
  댓글 수: 2
Jan
Jan 2012년 12월 13일
편집: Jan 2012년 12월 13일
Please explain the available input exactly: what is "a 2D plot in Matlab"? A photo of the screen, a screenshot saved to a graphics file, a FIG file, an open Matlab figure, a diagram in a printed paper or PDF file?
Sebsatien
Sebsatien 2012년 12월 14일
The inputs are the sinusoidal fonction values (a current) as y and the time values as x. I want to get all the generated values of y in a column and the generated values of x in another column in a text file.

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

답변 (1개)

Jan
Jan 2012년 12월 13일
It seems liek you do not have to extract the data from the figure, because you have constructed them directly. Then:
x = 1:length(I);
y = I;
fid = fopen('YourFileName.txt', 'w');
if fid == -1, error('Cannot open file for writing.'); end
fprintf(fid, '%g %g\n', transpose([x; y]));
fclose(fid);
  댓글 수: 1
Sebsatien
Sebsatien 2012년 12월 14일
Thanks. I will try this solution and see if it works ;)

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

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by