getting x and y values and writing them

3 Ansichten (letzte 30 Tage)
Mohamed Turkmani
Mohamed Turkmani am 16 Aug. 2022
Kommentiert: Mohamed Turkmani am 16 Aug. 2022
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?

Akzeptierte Antwort

KSSV
KSSV am 16 Aug. 2022
Bearbeitet: KSSV am 16 Aug. 2022
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') ;
  3 Kommentare
KSSV
KSSV am 16 Aug. 2022
Edited the code.
Mohamed Turkmani
Mohamed Turkmani am 16 Aug. 2022
thanks <3

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Polar Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by