getting x and y values and writing them

3 次查看(过去 30 天)
hi, i have created a user interface that gets sampling frequency and frequency from the user and plots it by the following code:
function pushbutton1_Callback(hObject, eventdata, handles)
sample = str2double(get(handles.edit1,'string'));
freq = str2double(get(handles.edit3,'string'));
if freq ~= 1000 && freq ~= 2000 && freq ~= 1600 && freq ~= 4000
f = msgbox("Enter values within the frequency rules");
end
nCyl = 1;
t=0:(1/sample):(nCyl/freq);
x=sin(2*pi*freq*t);
axes(handles.axes1);
plot(t,x);
my next step is to get the x and t values from the graph and write them all in a text file or a message text, how can i get the values of x and y that are plotted in the graph?

采纳的回答

KSSV
KSSV 2022-8-16
编辑:KSSV 2022-8-16
Already you have data in hand. If you want to write that into a file use:
data = [t(:) x(:)] ;
writematrix(data,'data.txt') ;
If you want to extract data from figure and write:
a = get(gca,'Children');
xdata = get(a, 'XData');
ydata = get(a, 'YData');
data = [xdata(:) ydata(:)] ;
writematrix(data,'data.txt') ;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polar Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by