getting x and y values and writing them

2 vues (au cours des 30 derniers jours)
Mohamed Turkmani
Mohamed Turkmani le 16 Août 2022
Commenté : Mohamed Turkmani le 16 Août 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?

Réponse acceptée

KSSV
KSSV le 16 Août 2022
Modifié(e) : KSSV le 16 Août 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 commentaires
KSSV
KSSV le 16 Août 2022
Edited the code.
Mohamed Turkmani
Mohamed Turkmani le 16 Août 2022
thanks <3

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by