Extract a MATLAB plot in a text file of points
1 次查看(过去 30 天)
显示 更早的评论
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.
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
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 个评论
回答(1 个)
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);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!