How to create a matrix from plot and export into a csv file

2 ビュー (過去 30 日間)
Manu Llamalo X
Manu Llamalo X 2013 年 10 月 30 日
編集済み: Marco 2013 年 10 月 30 日
Hi, I would like to create a matrix froma a plot and get the matrix to can export the plot into a csv file. I need the step between the funcion and plot and the matrix. >>x=linespace(-2,2,500) >>y=(x.^2).*(x<0)+1.*((0<x)&(x<1))+(-x+2).*(1<=x) >>plot(x,y,'r-'); >> THIS IS THE STEP THAT I NEED >>csvwrite('filename.csv',M)
M is the matrix,and I need to get it into the csv, so Can I get the y=f(x) to a matrix?
Thanks, Have a nice day.
Manu.

回答 (2 件)

Honglei Chen
Honglei Chen 2013 年 10 月 30 日
Do you mean something like this?
M = [get(gca,'XData') get(gca,'YData')]

Marco
Marco 2013 年 10 月 30 日
編集済み: Marco 2013 年 10 月 30 日
You might want to use the function FPLOT. Taken from the FPLOT documentation:
[X,Y] = fplot(fun,limits,...) returns the abscissas and ordinates for fun in X and Y.
Or you might want to use the function FEVAL for enhanced control on what range is going to be calculated. The use of teh FEVAL function was suggested to me here by Jonathan LeSage in his answer to a FPLOT related question of mine.

カテゴリ

Help Center および File ExchangeGeographic Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by